64 lines
1.8 KiB
Rust
64 lines
1.8 KiB
Rust
use askama::Template;
|
|
use optional_optional_user::OptionalOptionalUser;
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
use crate::User;
|
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq, OptionalOptionalUser)]
|
|
#[template(path = "signup.html")]
|
|
pub struct CreateUser {
|
|
pub username: String,
|
|
pub displayname: Option<String>,
|
|
pub email: Option<String>,
|
|
pub password: String,
|
|
pub pw_verify: String,
|
|
}
|
|
|
|
#[derive(
|
|
Debug, Clone, Template, Default, Deserialize, Serialize, PartialEq, Eq, OptionalOptionalUser,
|
|
)]
|
|
#[template(path = "signup_success.html")]
|
|
pub struct CreateUserSuccess(pub User);
|
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq)]
|
|
#[template(path = "login_post.html")]
|
|
pub struct LoginPost {
|
|
pub username: String,
|
|
pub password: String,
|
|
}
|
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq, OptionalOptionalUser)]
|
|
#[template(path = "login_get.html")]
|
|
pub struct LoginGet {
|
|
pub username: String,
|
|
pub password: String,
|
|
}
|
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq, OptionalOptionalUser)]
|
|
#[template(path = "logout_get.html")]
|
|
pub struct LogoutGet;
|
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq, OptionalOptionalUser)]
|
|
#[template(path = "logout_post.html")]
|
|
pub struct LogoutPost;
|
|
|
|
#[derive(Debug, Default, Template, Deserialize, Serialize, PartialEq, Eq, OptionalOptionalUser)]
|
|
#[template(path = "index.html")]
|
|
pub struct MainPage {
|
|
pub user: Option<User>,
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod test {
|
|
use super::*;
|
|
|
|
#[test]
|
|
fn main_page_has_optional_user() {
|
|
assert!(MainPage::default().has_optional_user());
|
|
}
|
|
|
|
#[test]
|
|
fn signup_success_has_no_optional_user() {
|
|
assert!(!CreateUserSuccess::default().has_optional_user());
|
|
}
|
|
}
|