backend: remove column salt from user
This commit is contained in:
parent
6ff16702f6
commit
2f136fbb01
2 changed files with 5 additions and 54 deletions
|
@ -2,65 +2,18 @@
|
||||||
|
|
||||||
use sea_orm::entity::prelude::*;
|
use sea_orm::entity::prelude::*;
|
||||||
|
|
||||||
#[derive(Copy, Clone, Default, Debug, DeriveEntity)]
|
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
|
||||||
pub struct Entity;
|
#[sea_orm(table_name = "user")]
|
||||||
|
|
||||||
impl EntityName for Entity {
|
|
||||||
fn table_name(&self) -> &str {
|
|
||||||
"user"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, DeriveModel, DeriveActiveModel, Eq)]
|
|
||||||
pub struct Model {
|
pub struct Model {
|
||||||
|
#[sea_orm(primary_key, auto_increment = false)]
|
||||||
pub id: Uuid,
|
pub id: Uuid,
|
||||||
pub name: String,
|
pub name: String,
|
||||||
|
#[sea_orm(unique)]
|
||||||
pub email: String,
|
pub email: String,
|
||||||
pub hash: String,
|
pub hash: String,
|
||||||
pub salt: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DeriveColumn)]
|
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
|
||||||
pub enum Column {
|
|
||||||
Id,
|
|
||||||
Name,
|
|
||||||
Email,
|
|
||||||
Hash,
|
|
||||||
Salt,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter, DerivePrimaryKey)]
|
|
||||||
pub enum PrimaryKey {
|
|
||||||
Id,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl PrimaryKeyTrait for PrimaryKey {
|
|
||||||
type ValueType = Uuid;
|
|
||||||
fn auto_increment() -> bool {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, EnumIter)]
|
|
||||||
pub enum Relation {}
|
pub enum Relation {}
|
||||||
|
|
||||||
impl ColumnTrait for Column {
|
|
||||||
type EntityName = Entity;
|
|
||||||
fn def(&self) -> ColumnDef {
|
|
||||||
match self {
|
|
||||||
Self::Id => ColumnType::Uuid.def(),
|
|
||||||
Self::Name => ColumnType::String(None).def(),
|
|
||||||
Self::Email => ColumnType::String(None).def().unique(),
|
|
||||||
Self::Hash => ColumnType::String(None).def(),
|
|
||||||
Self::Salt => ColumnType::String(None).def(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl RelationTrait for Relation {
|
|
||||||
fn def(&self) -> RelationDef {
|
|
||||||
panic!("No RelationDef")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ActiveModelBehavior for ActiveModel {}
|
impl ActiveModelBehavior for ActiveModel {}
|
||||||
|
|
|
@ -21,7 +21,6 @@ impl MigrationTrait for Migration {
|
||||||
.col(ColumnDef::new(User::Name).string().not_null())
|
.col(ColumnDef::new(User::Name).string().not_null())
|
||||||
.col(ColumnDef::new(User::Email).string().not_null().unique_key())
|
.col(ColumnDef::new(User::Email).string().not_null().unique_key())
|
||||||
.col(ColumnDef::new(User::Hash).string().not_null())
|
.col(ColumnDef::new(User::Hash).string().not_null())
|
||||||
.col(ColumnDef::new(User::Salt).string().not_null())
|
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
|
@ -41,5 +40,4 @@ enum User {
|
||||||
Name,
|
Name,
|
||||||
Email,
|
Email,
|
||||||
Hash,
|
Hash,
|
||||||
Salt,
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue