diff --git a/service/migrations/000011_create_users/up.sql b/service/migrations/000011_create_users/up.sql
index 4235954..0adabf0 100644
--- a/service/migrations/000011_create_users/up.sql
+++ b/service/migrations/000011_create_users/up.sql
@@ -4,5 +4,5 @@ CREATE TABLE IF NOT EXISTS users (
role TEXT NOT NULL,
first_name TEXT NOT NULL,
last_name TEXT NOT NULL,
- verified BOOLEAN NOT NULL DEFAULT FALSE,
+ verified BOOLEAN NOT NULL DEFAULT FALSE
);
\ No newline at end of file
diff --git a/service/src/auth/model.rs b/service/src/auth/model.rs
index 641ff93..e180ab4 100644
--- a/service/src/auth/model.rs
+++ b/service/src/auth/model.rs
@@ -27,6 +27,7 @@ impl RegisterUser {
role: "user".to_string(),
first_name: self.first_name,
last_name: self.last_name,
+ verified: false,
})
}
}
@@ -45,6 +46,7 @@ pub struct QueryUser {
pub role: String,
pub first_name: String,
pub last_name: String,
+ pub verified: bool,
}
impl QueryUser {
@@ -67,6 +69,7 @@ pub struct InsertUser {
pub role: String,
pub first_name: String,
pub last_name: String,
+ pub verified: bool,
}
impl InsertUser {
diff --git a/service/src/auth/routes.rs b/service/src/auth/routes.rs
index 941f6ba..210c973 100644
--- a/service/src/auth/routes.rs
+++ b/service/src/auth/routes.rs
@@ -350,6 +350,7 @@ pub fn init_routes(config: &mut web::ServiceConfig) {
};
let mut u = r.convert_to_insert().unwrap();
u.role = "admin".to_string();
+ u.verified = true;
let _ = InsertUser::insert(u);
config.service(web::scope("auth")
.service(register)
diff --git a/service/src/db/schema.rs b/service/src/db/schema.rs
index 6690560..3e6f3e5 100644
--- a/service/src/db/schema.rs
+++ b/service/src/db/schema.rs
@@ -46,5 +46,6 @@ diesel::table! {
role -> Text,
first_name -> Text,
last_name -> Text,
+ verified -> Bool,
}
}
\ No newline at end of file
diff --git a/ui/src/components/Topbar/index.tsx b/ui/src/components/Topbar/index.tsx
index c7f14ab..422154d 100644
--- a/ui/src/components/Topbar/index.tsx
+++ b/ui/src/components/Topbar/index.tsx
@@ -10,6 +10,7 @@ import {
Card,
Checkbox,
Container,
+ Grid,
Group,
Menu,
Modal,
@@ -147,22 +148,38 @@ export default function Topbar() {
{user.role}
-
+
+
+
+
+
+
+
+
@@ -207,9 +224,6 @@ function LoginModal({ type, toggle, setUser }: LoginModalProps) {
if (!/[!@#$%^&*]/.test(value)) {
return 'Password must contain at least one special character';
}
- if (/(.)\1\1/.test(value)) {
- return 'Password must not contain more than 2 repeating characters';
- }
return null;
}
@@ -223,13 +237,12 @@ function LoginModal({ type, toggle, setUser }: LoginModalProps) {
return null;
}
- const form = useForm({
+ const registerForm = useForm({
initialValues: {
firstName: '',
lastName: '',
email: '',
- password: '',
- remember: false
+ password: ''
},
validate: {
firstName: (value) => (value.trim().length > 0 ? null : 'First name is required'),
@@ -239,10 +252,26 @@ function LoginModal({ type, toggle, setUser }: LoginModalProps) {
}
});
+ const loginForm = useForm({
+ initialValues: {
+ email: '',
+ password: '',
+ remember: false
+ }
+ });
+
+ const resetForm = useForm({
+ initialValues: {
+ email: ''
+ }
+ });
+
function onClose() {
toggle(undefined);
- if (!form.values.remember) {
- form.reset();
+ registerForm.reset();
+ resetForm.reset();
+ if (!loginForm.values.remember) {
+ loginForm.reset();
}
}
@@ -258,8 +287,8 @@ function LoginModal({ type, toggle, setUser }: LoginModalProps) {
-