fix: guest membership
This commit is contained in:
parent
80c03483ee
commit
9acb688379
2 changed files with 50 additions and 2 deletions
|
|
@ -368,6 +368,7 @@ pub async fn signup(
|
|||
/// 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(
|
||||
rls_conn: crate::auth::RlsConn,
|
||||
State(pool): State<PgPool>,
|
||||
session: Session,
|
||||
Json(req): Json<GuestLoginRequest>,
|
||||
|
|
@ -393,6 +394,17 @@ pub async fn guest_login(
|
|||
// Create guest user (no password) - trigger creates avatar automatically
|
||||
let user_id = users::create_guest_user(&pool, &guest_name).await?;
|
||||
|
||||
// Set RLS context to the new guest user for membership creation
|
||||
rls_conn
|
||||
.set_user_id(user_id)
|
||||
.await
|
||||
.map_err(|e| AppError::Internal(format!("Failed to set RLS context: {}", e)))?;
|
||||
|
||||
// Create membership for the guest so their position can be persisted
|
||||
let mut conn = rls_conn.acquire().await;
|
||||
memberships::create_membership_conn(&mut *conn, user_id, realm.id, RealmRole::Member).await?;
|
||||
drop(conn);
|
||||
|
||||
// Set up tower session (same as regular user login)
|
||||
session
|
||||
.insert(SESSION_USER_ID_KEY, user_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue