Rename user -> users
This commit is contained in:
parent
f44f15d2b6
commit
205a3b165e
9 changed files with 22 additions and 25 deletions
|
|
@ -6,5 +6,5 @@ pub mod groups;
|
|||
pub mod ticks;
|
||||
pub mod track2_groups;
|
||||
pub mod tracks;
|
||||
pub mod user;
|
||||
pub mod user_tracks;
|
||||
pub mod users;
|
||||
|
|
|
|||
|
|
@ -4,5 +4,5 @@ pub use super::groups::Entity as Groups;
|
|||
pub use super::ticks::Entity as Ticks;
|
||||
pub use super::track2_groups::Entity as Track2Groups;
|
||||
pub use super::tracks::Entity as Tracks;
|
||||
pub use super::user::Entity as User;
|
||||
pub use super::user_tracks::Entity as UserTracks;
|
||||
pub use super::users::Entity as Users;
|
||||
|
|
|
|||
|
|
@ -46,9 +46,9 @@ impl Related<super::user_tracks::Entity> for Entity {
|
|||
}
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
impl Related<super::users::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
super::user_tracks::Relation::User.def()
|
||||
super::user_tracks::Relation::Users.def()
|
||||
}
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::user_tracks::Relation::Tracks.def().rev())
|
||||
|
|
|
|||
|
|
@ -22,13 +22,13 @@ pub enum Relation {
|
|||
)]
|
||||
Tracks,
|
||||
#[sea_orm(
|
||||
belongs_to = "super::user::Entity",
|
||||
belongs_to = "super::users::Entity",
|
||||
from = "Column::UserId",
|
||||
to = "super::user::Column::Id",
|
||||
to = "super::users::Column::Id",
|
||||
on_update = "NoAction",
|
||||
on_delete = "NoAction"
|
||||
)]
|
||||
User,
|
||||
Users,
|
||||
}
|
||||
|
||||
impl Related<super::tracks::Entity> for Entity {
|
||||
|
|
@ -37,9 +37,9 @@ impl Related<super::tracks::Entity> for Entity {
|
|||
}
|
||||
}
|
||||
|
||||
impl Related<super::user::Entity> for Entity {
|
||||
impl Related<super::users::Entity> for Entity {
|
||||
fn to() -> RelationDef {
|
||||
Relation::User.def()
|
||||
Relation::Users.def()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use std::default::default;
|
|||
use bcrypt::*;
|
||||
// TODO Add option for argon2 https://docs.rs/argon2/latest/argon2/
|
||||
use either::Either::{self, Left, Right};
|
||||
use rocket::response::status::Unauthorized;
|
||||
use rocket::http::Status;
|
||||
use sea_orm::entity::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ use crate::{
|
|||
use super::tracks;
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq, Serialize, Deserialize)]
|
||||
#[sea_orm(table_name = "user")]
|
||||
#[sea_orm(table_name = "users")]
|
||||
pub struct Model {
|
||||
#[sea_orm(primary_key)]
|
||||
#[serde(skip_deserializing)]
|
||||
|
|
@ -43,7 +43,7 @@ impl Related<super::tracks::Entity> for Entity {
|
|||
}
|
||||
|
||||
fn via() -> Option<RelationDef> {
|
||||
Some(super::user_tracks::Relation::User.def().rev())
|
||||
Some(super::user_tracks::Relation::Users.def().rev())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -65,11 +65,8 @@ impl ActiveModel {
|
|||
impl Model {
|
||||
pub fn check_password(
|
||||
self,
|
||||
password: String,
|
||||
) -> std::result::Result<Self, Either<Unauthorized<()>, ErrorResponder>> {
|
||||
match verify(password, &self.password_hash) {
|
||||
Ok(true) => Ok(self),
|
||||
Ok(false) => Err(Left(Unauthorized(None))),
|
||||
Err(err) => Err(Right(Error::from(err).into())),
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue