fix: user not allowed

This commit is contained in:
Fu Zi Xiang 2023-11-07 01:17:08 +08:00
parent 17044ad4f0
commit 32390676f1
No known key found for this signature in database
3 changed files with 12 additions and 12 deletions

View File

@ -8,7 +8,7 @@ GOTRUE_JWT_SECRET=hello456
# user sign up will automatically be confirmed if this is set to true
# if you have OAuth2 set up or smtp configured, you can set this to false
# to enforce email confirmation or OAuth2 login instead
GOTRUE_MAILER_AUTOCONFIRM=true
GOTRUE_MAILER_AUTOCONFIRM=false
# if you enable mail confirmation, you need to set the SMTP configuration below
GOTRUE_SMTP_HOST=smtp.gmail.com

View File

@ -13,6 +13,7 @@ we recommend using cloud compute services (as your host server) such as
## Software Requirements
- [docker compose](https://docs.docker.com/compose)
This is needed be installed in your host server
- We recommend using approach as proposed by offical docker website: [Install Docker Engine](https://docs.docker.com/engine/install/)
## Steps

View File

@ -231,21 +231,20 @@ async fn setup_admin_account(
Err(err.into())
}
},
Ok(resp) => match resp {
gotrue_entity::dto::SignUpResponse::Authenticated(resp) => {
tracing::info!(
"Admin user already created and authenticated at {:?}",
resp.user.email_confirmed_at
);
Ok(())
},
gotrue_entity::dto::SignUpResponse::NotAuthenticated(user) => match user.role.as_str() {
Ok(resp) => {
let admin_user = {
match resp {
gotrue_entity::dto::SignUpResponse::Authenticated(resp) => resp.user,
gotrue_entity::dto::SignUpResponse::NotAuthenticated(user) => user,
}
};
match admin_user.role.as_str() {
"supabase_admin" => {
tracing::info!("Admin user already created and set role to supabase_admin");
Ok(())
},
_ => {
let user_id = user.id.parse::<uuid::Uuid>().unwrap();
let user_id = admin_user.id.parse::<uuid::Uuid>().unwrap();
let result = sqlx::query(
r#"
UPDATE auth.users
@ -263,7 +262,7 @@ async fn setup_admin_account(
Ok(())
},
},
}
},
}
}