Allow to login with OIDC
This commit is contained in:
parent
f556fec3bb
commit
7a2ff7ad1d
12 changed files with 782 additions and 29 deletions
|
|
@ -5,6 +5,7 @@ mod m20230520_203638_household;
|
|||
mod m20230529_184433_ingredients;
|
||||
mod m20230618_163416_recipe;
|
||||
mod m20230629_151746_recipe_person_count;
|
||||
mod m20230726_203858_oidc;
|
||||
|
||||
pub struct Migrator;
|
||||
|
||||
|
|
@ -17,6 +18,7 @@ impl MigratorTrait for Migrator {
|
|||
Box::new(m20230529_184433_ingredients::Migration),
|
||||
Box::new(m20230618_163416_recipe::Migration),
|
||||
Box::new(m20230629_151746_recipe_person_count::Migration),
|
||||
Box::new(m20230726_203858_oidc::Migration),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ pub(crate) enum User {
|
|||
Id,
|
||||
Name,
|
||||
Password,
|
||||
OpenIdSubject,
|
||||
}
|
||||
|
||||
#[async_trait::async_trait]
|
||||
|
|
|
|||
40
migration/src/m20230726_203858_oidc.rs
Normal file
40
migration/src/m20230726_203858_oidc.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use sea_orm_migration::prelude::*;
|
||||
|
||||
use crate::m20220101_000001_account::User;
|
||||
|
||||
#[derive(DeriveMigrationName)]
|
||||
pub struct Migration;
|
||||
|
||||
#[async_trait::async_trait]
|
||||
impl MigrationTrait for Migration {
|
||||
async fn up(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(User::Table)
|
||||
.modify_column(ColumnDef::new(User::Password).null())
|
||||
.add_column(ColumnDef::new(User::OpenIdSubject).string().null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
async fn down(&self, manager: &SchemaManager) -> Result<(), DbErr> {
|
||||
manager.exec_stmt(
|
||||
Query::delete()
|
||||
.from_table(User::Table)
|
||||
.cond_where(Expr::col(User::Password).is_null())
|
||||
.to_owned(),
|
||||
).await?;
|
||||
|
||||
manager
|
||||
.alter_table(
|
||||
Table::alter()
|
||||
.table(User::Table)
|
||||
.drop_column(User::OpenIdSubject)
|
||||
.modify_column(ColumnDef::new(User::Password).not_null())
|
||||
.to_owned(),
|
||||
)
|
||||
.await
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue