User management completed. Leptos upgraded to 0.5.0.
This commit is contained in:
+13
-1
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user