feat: add the ability to resync props

This commit is contained in:
Evan Carroll 2026-01-15 19:02:34 -06:00
parent 8447fdef5d
commit e57323ff3f
5 changed files with 180 additions and 36 deletions

View file

@ -20,8 +20,8 @@ use chattyness_error::AppError;
use crate::auth::{
session::{
hash_token, generate_token, SESSION_CURRENT_REALM_KEY, SESSION_GUEST_ID_KEY,
SESSION_LOGIN_TYPE_KEY, SESSION_ORIGINAL_DEST_KEY, SESSION_USER_ID_KEY,
SESSION_CURRENT_REALM_KEY, SESSION_LOGIN_TYPE_KEY, SESSION_ORIGINAL_DEST_KEY,
SESSION_USER_ID_KEY,
},
AuthUser, OptionalAuthUser,
};
@ -328,6 +328,9 @@ pub async fn signup(
}
/// Guest login handler.
///
/// Creates a real user account with the 'guest' tag. Guests are regular users
/// with limited capabilities (no prop pickup, etc.) that can be reaped after 24 hours.
pub async fn guest_login(
State(pool): State<PgPool>,
session: Session,
@ -348,27 +351,15 @@ pub async fn guest_login(
));
}
// Generate guest name and session token
// Generate guest name
let guest_name = guests::generate_guest_name();
let token = generate_token();
let token_hash = hash_token(&token);
let expires_at = guests::guest_session_expiry();
// Create guest session in database
let guest_id = guests::create_guest_session(
&pool,
&guest_name,
realm.id,
&token_hash,
None, // user_agent
None, // ip_address
expires_at,
)
.await?;
// Create guest user (no password) - trigger creates avatar automatically
let user_id = users::create_guest_user(&pool, &guest_name).await?;
// Set up tower session
// Set up tower session (same as regular user login)
session
.insert(SESSION_GUEST_ID_KEY, guest_id)
.insert(SESSION_USER_ID_KEY, user_id)
.await
.map_err(|e| AppError::Internal(format!("Session error: {}", e)))?;
session
@ -384,7 +375,7 @@ pub async fn guest_login(
Ok(Json(GuestLoginResponse {
guest_name,
guest_id,
user_id,
redirect_url,
realm: RealmSummary {
id: realm.id,