- update: schema now sets the skills column to prevent a crash
- update: frontend to only pass the session id - update: launcher to pass the session correctly - update: validate session response now returns the session id and user id to the requester - update: auth client based on session id instead of a jwt token
This commit is contained in:
@@ -2,7 +2,8 @@ use serde::{Deserialize, Serialize};
|
||||
use sqlx::{FromRow, Row};
|
||||
use std::sync::Arc;
|
||||
use tokio::sync::Mutex;
|
||||
use utils::redis_cache::{Cache, RedisCache}; // Import RedisCache
|
||||
use utils::redis_cache::{Cache, RedisCache};
|
||||
// Import RedisCache
|
||||
|
||||
#[derive(Debug, FromRow, Serialize, Deserialize)]
|
||||
pub struct Character {
|
||||
@@ -74,14 +75,16 @@ impl CharacterRepository {
|
||||
looks: serde_json::Value,
|
||||
position: serde_json::Value,
|
||||
) -> Result<i32, sqlx::Error> {
|
||||
let default_skills = "[{\"id\": 11, \"level\": 1}, {\"id\": 12, \"level\": 1}, {\"id\": 16, \"level\": 1}, {\"id\": 19, \"level\": 1}, {\"id\": 20, \"level\": 1}, {\"id\": 21, \"level\": 1}, {\"id\": 26, \"level\": 1}, {\"id\": 41, \"level\": 1}, {\"id\": 42, \"level\": 1}, {\"id\": 43, \"level\": 1}, {\"id\": 46, \"level\": 1}, {\"id\": 47, \"level\": 1}, {\"id\": 48, \"level\": 1}, {\"id\": 49, \"level\": 1}, {\"id\": 50, \"level\": 1}]";
|
||||
let result = sqlx::query(
|
||||
"INSERT INTO characters (user_id, name, inventory, stats, looks, position, created_at, updated_at, is_active) \
|
||||
VALUES ($1, $2, $3, $4, $5, $6, NOW(), NOW(), true) RETURNING id",
|
||||
"INSERT INTO characters (user_id, name, inventory, stats, skills, looks, position, created_at, updated_at, is_active) \
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, NOW(), NOW(), true) RETURNING id",
|
||||
)
|
||||
.bind(user_id)
|
||||
.bind(name)
|
||||
.bind(inventory)
|
||||
.bind(stats)
|
||||
.bind(default_skills)
|
||||
.bind(looks)
|
||||
.bind(position)
|
||||
.fetch_one(&self.pool)
|
||||
@@ -150,7 +153,7 @@ impl CharacterRepository {
|
||||
|
||||
// Fetch from database
|
||||
let characters = sqlx::query_as::<_, Character>(
|
||||
"SELECT id, user_id, name, inventory, stats, looks, position, created_at, updated_at, extract(epoch from (deleted_at - now()))::BIGINT as deleted_at, is_active FROM characters WHERE user_id = $1 AND is_active = true",
|
||||
"SELECT id, user_id, name, inventory, stats, skills, looks, position, created_at, updated_at, extract(epoch from (deleted_at - now()))::BIGINT as deleted_at, is_active FROM characters WHERE user_id = $1 AND is_active = true",
|
||||
)
|
||||
.bind(user_id)
|
||||
.fetch_all(&self.pool)
|
||||
|
||||
Reference in New Issue
Block a user