style: use const generic for token length instead of multiple functions
Simplifies codebase a bit and avoids having to add another function in future if we need another length of token
This commit is contained in:
parent
f752cddd73
commit
407460d2aa
6 changed files with 16 additions and 22 deletions
|
@ -3,7 +3,7 @@ use lettre::message::MultiPart;
|
|||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
|
||||
use crate::{Data, error::Error, utils::generate_refresh_token};
|
||||
use crate::{Data, error::Error, utils::generate_token};
|
||||
|
||||
use super::Me;
|
||||
|
||||
|
@ -23,7 +23,7 @@ impl EmailToken {
|
|||
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub async fn new(data: &Data, me: Me) -> Result<(), Error> {
|
||||
let token = generate_refresh_token()?;
|
||||
let token = generate_token::<32>()?;
|
||||
|
||||
let email_token = EmailToken {
|
||||
user_uuid: me.uuid,
|
||||
|
|
|
@ -12,10 +12,10 @@ use serde::{Deserialize, Serialize};
|
|||
use uuid::Uuid;
|
||||
|
||||
use crate::{
|
||||
Data,
|
||||
error::Error,
|
||||
schema::users,
|
||||
utils::{PASSWORD_REGEX, generate_refresh_token, global_checks, user_uuid_from_identifier},
|
||||
utils::{generate_token, global_checks, user_uuid_from_identifier, PASSWORD_REGEX},
|
||||
Data
|
||||
};
|
||||
|
||||
#[derive(Serialize, Deserialize)]
|
||||
|
@ -48,7 +48,7 @@ impl PasswordResetToken {
|
|||
|
||||
#[allow(clippy::new_ret_no_self)]
|
||||
pub async fn new(data: &Data, identifier: String) -> Result<(), Error> {
|
||||
let token = generate_refresh_token()?;
|
||||
let token = generate_token::<32>()?;
|
||||
|
||||
let mut conn = data.pool.get().await?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue