fix: reuse existing user/session in auth_handler via user_id param
This commit is contained in:
parent
f062cc4a3e
commit
c87536d24a
1 changed files with 4 additions and 1 deletions
|
|
@ -48,10 +48,13 @@ pub async fn auth_handler(
|
||||||
Query(params): Query<HashMap<String, String>>,
|
Query(params): Query<HashMap<String, String>>,
|
||||||
) -> impl IntoResponse {
|
) -> impl IntoResponse {
|
||||||
let bot_name = params.get("bot_name").cloned().unwrap_or_default();
|
let bot_name = params.get("bot_name").cloned().unwrap_or_default();
|
||||||
|
let existing_user_id = params
|
||||||
|
.get("user_id")
|
||||||
|
.and_then(|s| Uuid::parse_str(s).ok());
|
||||||
|
|
||||||
let user_id = {
|
let user_id = {
|
||||||
let mut sm = state.session_manager.lock().await;
|
let mut sm = state.session_manager.lock().await;
|
||||||
match sm.get_or_create_anonymous_user(None) {
|
match sm.get_or_create_anonymous_user(existing_user_id) {
|
||||||
Ok(id) => id,
|
Ok(id) => id,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to create anonymous user: {}", e);
|
error!("Failed to create anonymous user: {}", e);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue