Added a function to set a member roles to admin
This commit is contained in:
parent
10297f9114
commit
0b8d6e2cc2
@ -17,6 +17,7 @@ struct Cli {
|
||||
enum Commands {
|
||||
Serve,
|
||||
CreateAdminMember,
|
||||
SetMemberAdmin { relatiecode: String },
|
||||
}
|
||||
|
||||
pub async fn parse(pool: PgPool) {
|
||||
@ -29,6 +30,11 @@ pub async fn parse(pool: PgPool) {
|
||||
Some(Commands::CreateAdminMember) => {
|
||||
create_admin_member(&pool).await.unwrap();
|
||||
}
|
||||
Some(Commands::SetMemberAdmin {
|
||||
relatiecode: member_id,
|
||||
}) => {
|
||||
set_member_admin(&pool, member_id).await.unwrap();
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
@ -54,3 +60,17 @@ pub async fn create_admin_member(pool: &PgPool) -> Result<(), sqlx::Error> {
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn set_member_admin(pool: &PgPool, id: &str) -> Result<(), sqlx::Error> {
|
||||
sqlx::query!(
|
||||
"
|
||||
UPDATE ONLY members SET roles = $1 WHERE member_id = $2
|
||||
",
|
||||
Roles::ADMIN.bits() as i64,
|
||||
id
|
||||
)
|
||||
.execute(pool)
|
||||
.await?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user