Authentication

This commit is contained in:
Bad Manners 2025-04-07 23:55:35 -03:00
parent 2722c7d40a
commit a5e3fb2850
19 changed files with 723 additions and 98 deletions

View file

@ -4,5 +4,7 @@ pub mod prelude;
pub mod samey_post;
pub mod samey_post_source;
pub mod samey_session;
pub mod samey_tag;
pub mod samey_tag_post;
pub mod samey_user;

View file

@ -2,5 +2,7 @@
pub use super::samey_post::Entity as SameyPost;
pub use super::samey_post_source::Entity as SameyPostSource;
pub use super::samey_session::Entity as SameySession;
pub use super::samey_tag::Entity as SameyTag;
pub use super::samey_tag_post::Entity as SameyTagPost;
pub use super::samey_user::Entity as SameyUser;

View file

@ -7,6 +7,7 @@ use sea_orm::entity::prelude::*;
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub uploader_id: i32,
pub media: String,
pub width: i32,
pub height: i32,
@ -35,6 +36,14 @@ pub enum Relation {
SameyPostSource,
#[sea_orm(has_many = "super::samey_tag_post::Entity")]
SameyTagPost,
#[sea_orm(
belongs_to = "super::samey_user::Entity",
from = "Column::UploaderId",
to = "super::samey_user::Column::Id",
on_update = "NoAction",
on_delete = "Cascade"
)]
SameyUser,
}
impl Related<super::samey_post_source::Entity> for Entity {
@ -49,4 +58,10 @@ impl Related<super::samey_tag_post::Entity> for Entity {
}
}
impl Related<super::samey_user::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyUser.def()
}
}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -0,0 +1,18 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.8
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "samey_session")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
pub session_id: String,
pub data: Json,
pub expiry_date: String,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {}
impl ActiveModelBehavior for ActiveModel {}

View file

@ -0,0 +1,28 @@
//! `SeaORM` Entity, @generated by sea-orm-codegen 1.1.8
use sea_orm::entity::prelude::*;
#[derive(Clone, Debug, PartialEq, DeriveEntityModel, Eq)]
#[sea_orm(table_name = "samey_user")]
pub struct Model {
#[sea_orm(primary_key)]
pub id: i32,
#[sea_orm(unique)]
pub username: String,
pub password: String,
pub is_admin: bool,
}
#[derive(Copy, Clone, Debug, EnumIter, DeriveRelation)]
pub enum Relation {
#[sea_orm(has_many = "super::samey_post::Entity")]
SameyPost,
}
impl Related<super::samey_post::Entity> for Entity {
fn to() -> RelationDef {
Relation::SameyPost.def()
}
}
impl ActiveModelBehavior for ActiveModel {}