2023-05-17 17:09:00 +00:00
|
|
|
use askama::Template;
|
2023-05-28 19:20:55 +00:00
|
|
|
use serde::{Deserialize, Serialize};
|
2023-05-17 17:09:00 +00:00
|
|
|
|
2023-05-29 21:25:50 +00:00
|
|
|
use crate::User;
|
|
|
|
|
2023-06-13 19:34:54 +00:00
|
|
|
pub trait MaybeOptionalUser {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-06-02 21:15:13 +00:00
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
2023-05-17 20:40:06 +00:00
|
|
|
#[template(path = "signup.html")]
|
2023-05-17 17:09:00 +00:00
|
|
|
pub struct CreateUser {
|
|
|
|
pub username: String,
|
|
|
|
pub displayname: Option<String>,
|
|
|
|
pub email: Option<String>,
|
|
|
|
pub password: String,
|
|
|
|
pub pw_verify: String,
|
2023-06-13 19:34:54 +00:00
|
|
|
user: Option<User>,
|
|
|
|
}
|
|
|
|
impl MaybeOptionalUser for CreateUser {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
true
|
|
|
|
}
|
2023-05-17 17:09:00 +00:00
|
|
|
}
|
2023-05-28 19:20:55 +00:00
|
|
|
|
2023-06-03 22:45:19 +00:00
|
|
|
#[derive(Debug, Clone, Template, Default, Deserialize, Serialize, PartialEq, Eq)]
|
|
|
|
#[template(path = "signup_success.html")]
|
2023-06-13 19:34:54 +00:00
|
|
|
pub struct CreateUserSuccess {
|
|
|
|
pub user: User,
|
|
|
|
}
|
|
|
|
impl MaybeOptionalUser for CreateUserSuccess {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2023-06-03 22:45:19 +00:00
|
|
|
|
2023-06-02 21:15:13 +00:00
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
2023-05-28 19:20:55 +00:00
|
|
|
#[template(path = "login_post.html")]
|
|
|
|
pub struct LoginPost {
|
|
|
|
pub username: String,
|
|
|
|
pub password: String,
|
|
|
|
}
|
2023-06-13 19:34:54 +00:00
|
|
|
impl MaybeOptionalUser for LoginPost {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2023-05-28 19:20:55 +00:00
|
|
|
|
2023-06-02 21:15:13 +00:00
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
2023-05-28 19:20:55 +00:00
|
|
|
#[template(path = "login_get.html")]
|
|
|
|
pub struct LoginGet {
|
|
|
|
pub username: String,
|
|
|
|
pub password: String,
|
|
|
|
}
|
2023-06-13 19:34:54 +00:00
|
|
|
impl MaybeOptionalUser for LoginGet {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2023-05-29 21:25:50 +00:00
|
|
|
|
2023-06-02 21:15:13 +00:00
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
2023-05-29 21:25:50 +00:00
|
|
|
#[template(path = "logout_get.html")]
|
|
|
|
pub struct LogoutGet;
|
2023-06-13 19:34:54 +00:00
|
|
|
impl MaybeOptionalUser for LogoutGet {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2023-05-29 21:25:50 +00:00
|
|
|
|
2023-06-02 21:15:13 +00:00
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
2023-05-29 21:25:50 +00:00
|
|
|
#[template(path = "logout_post.html")]
|
|
|
|
pub struct LogoutPost;
|
2023-06-13 19:34:54 +00:00
|
|
|
impl MaybeOptionalUser for LogoutPost {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
}
|
2023-05-29 21:25:50 +00:00
|
|
|
|
2023-06-02 21:15:13 +00:00
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
2023-05-29 21:25:50 +00:00
|
|
|
#[template(path = "index.html")]
|
2023-06-08 16:16:38 +00:00
|
|
|
pub struct MainPage {
|
2023-05-29 21:25:50 +00:00
|
|
|
pub user: Option<User>,
|
|
|
|
}
|
2023-06-13 19:34:54 +00:00
|
|
|
impl MaybeOptionalUser for MainPage {
|
|
|
|
fn has_optional_user() -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
}
|