User management completed. Leptos upgraded to 0.5.0.

This commit is contained in:
2023-10-09 17:33:20 +02:00
parent a7188e8153
commit e7af2d402d
18 changed files with 697 additions and 334 deletions
+13 -1
View File
@@ -1,5 +1,6 @@
//use chrono::{NaiveDate, NaiveTime, Weekday};
//use rust_decimal::Decimal;
#![allow(unused_variables)]
use serde::{Deserialize, Serialize};
//use uuid::Uuid;
use validator::Validate;
@@ -51,11 +52,16 @@ impl User {
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]
pub struct UserProfile {
#[validate(length(min = 1,message = "Username cannot be empty"))]
login: String,
#[validate(must_match(other = "password_ver", message = "Passwords doesn't match"))]
password: Option<String>,
password_ver: Option<String>,
full_name: String,
#[validate(email(message = "Enter valid email address"))]
email: String,
get_emails: Option<String>
get_emails: Option<String>,
admin: Option<String>
}
impl UserProfile {
@@ -75,6 +81,12 @@ impl UserProfile {
pub fn get_emails(&self) -> bool {
self.get_emails.is_some()
}
pub fn admin(&self) -> bool {
self.admin.is_some()
}
pub fn password(&self) -> &Option<String> {
&self.password
}
}
#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Validate, Default)]