mirror of
https://github.com/outbackdingo/optimclaw.git
synced 2026-08-25 14:53:34 +00:00
fix: guard created_by FK in user creation handler
The auth identity user_id (from owner_id scope) may not match any user row in the DB, causing a FK violation on the created_by column. Check that the referenced user exists before setting created_by. Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
27c6d1d6b7
commit
6cc77fe162
@@ -61,7 +61,10 @@ pub async fn users_create_handler(
|
||||
created_at: now,
|
||||
updated_at: now,
|
||||
last_login_at: None,
|
||||
created_by: Some(user.user_id.clone()),
|
||||
created_by: match store.get_user(&user.user_id).await {
|
||||
Ok(Some(_)) => Some(user.user_id.clone()),
|
||||
_ => None,
|
||||
},
|
||||
metadata: serde_json::json!({}),
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user