"fix: add family to authorized_families on create and OAuth login
This commit is contained in:
@@ -221,6 +221,7 @@ pub struct CreateMyFamilyResponse {
|
||||
)]
|
||||
pub async fn create_my_family(
|
||||
auth_session: AuthSession<AuthBackend>,
|
||||
session: Session,
|
||||
State(db): State<DatabaseConnection>,
|
||||
Json(payload): Json<CreateMyFamilyRequest>,
|
||||
) -> Result<Json<CreateMyFamilyResponse>, StatusCode> {
|
||||
@@ -247,6 +248,17 @@ pub async fn create_my_family(
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
|
||||
let mut authorized_families: Vec<i32> = session
|
||||
.get("authorized_families")
|
||||
.await
|
||||
.unwrap_or(None)
|
||||
.unwrap_or_default();
|
||||
authorized_families.push(family.id);
|
||||
session
|
||||
.insert("authorized_families", authorized_families)
|
||||
.await
|
||||
.map_err(|_| StatusCode::INTERNAL_SERVER_ERROR)?;
|
||||
|
||||
Ok(Json(CreateMyFamilyResponse {
|
||||
family_id: family.id,
|
||||
user_id: current_user.id,
|
||||
|
||||
Reference in New Issue
Block a user