Log errors in the user module
This commit is contained in:
parent
b0f0633338
commit
7b9df97a32
6 changed files with 199 additions and 118 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use chrono::{Duration, prelude::*};
|
||||
use rand::distr::{Alphanumeric, SampleString};
|
||||
use sqlx::Sqlite;
|
||||
use strum_macros::Display;
|
||||
|
||||
use super::{Connection, DBError, Result};
|
||||
use crate::{
|
||||
|
|
@ -9,27 +10,27 @@ use crate::{
|
|||
hash::{hash, verify_password},
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum SignUpResult {
|
||||
UserAlreadyExists,
|
||||
UserCreatedWaitingForValidation(String), // Validation token.
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum UpdateUserResult {
|
||||
EmailAlreadyTaken,
|
||||
UserUpdatedWaitingForRevalidation(String), // Validation token.
|
||||
Ok,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum ValidationResult {
|
||||
UnknownUser,
|
||||
ValidationExpired,
|
||||
Ok(String, i64), // Returns token and user id.
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum SignInResult {
|
||||
UserNotFound,
|
||||
WrongPassword,
|
||||
|
|
@ -37,20 +38,20 @@ pub enum SignInResult {
|
|||
Ok(String, i64), // Returns token and user id.
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum AuthenticationResult {
|
||||
NotValidToken,
|
||||
Ok(i64), // Returns user id.
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum GetTokenResetPasswordResult {
|
||||
PasswordAlreadyReset,
|
||||
EmailUnknown,
|
||||
Ok(String),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Display)]
|
||||
pub enum ResetPasswordResult {
|
||||
ResetTokenExpired,
|
||||
Ok,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue