@ -1,3 +1,4 @@
use crate ::util ::{ format_date , get_uuid , retry } ;
use chrono ::{ NaiveDateTime , TimeDelta , Utc } ;
use chrono ::{ NaiveDateTime , TimeDelta , Utc } ;
use serde_json ::Value ;
use serde_json ::Value ;
@ -90,7 +91,7 @@ impl User {
let email = email . to_lowercase ( ) ;
let email = email . to_lowercase ( ) ;
Self {
Self {
uuid : crate::util :: get_uuid( ) ,
uuid : get_uuid( ) ,
enabled : true ,
enabled : true ,
created_at : now ,
created_at : now ,
updated_at : now ,
updated_at : now ,
@ -107,7 +108,7 @@ impl User {
salt : crypto ::get_random_bytes ::< 64 > ( ) . to_vec ( ) ,
salt : crypto ::get_random_bytes ::< 64 > ( ) . to_vec ( ) ,
password_iterations : CONFIG . password_iterations ( ) ,
password_iterations : CONFIG . password_iterations ( ) ,
security_stamp : crate::util :: get_uuid( ) ,
security_stamp : get_uuid( ) ,
stamp_exception : None ,
stamp_exception : None ,
password_hint : None ,
password_hint : None ,
@ -188,7 +189,7 @@ impl User {
}
}
pub fn reset_security_stamp ( & mut self ) {
pub fn reset_security_stamp ( & mut self ) {
self . security_stamp = crate ::util ::get_uuid ( ) ;
self . security_stamp = get_uuid ( ) ;
}
}
/// Set the stamp_exception to only allow a subsequent request matching a specific route using the current security-stamp.
/// Set the stamp_exception to only allow a subsequent request matching a specific route using the current security-stamp.
@ -259,6 +260,7 @@ impl User {
"forcePasswordReset" : false ,
"forcePasswordReset" : false ,
"avatarColor" : self . avatar_color ,
"avatarColor" : self . avatar_color ,
"usesKeyConnector" : false ,
"usesKeyConnector" : false ,
"creationDate" : format_date ( & self . created_at ) ,
"object" : "profile" ,
"object" : "profile" ,
} )
} )
}
}
@ -340,7 +342,7 @@ impl User {
let updated_at = Utc ::now ( ) . naive_utc ( ) ;
let updated_at = Utc ::now ( ) . naive_utc ( ) ;
db_run ! { conn : {
db_run ! { conn : {
crate ::util ::retry ( | | {
retry ( | | {
diesel ::update ( users ::table )
diesel ::update ( users ::table )
. set ( users ::updated_at . eq ( updated_at ) )
. set ( users ::updated_at . eq ( updated_at ) )
. execute ( conn )
. execute ( conn )
@ -357,7 +359,7 @@ impl User {
async fn _update_revision ( uuid : & str , date : & NaiveDateTime , conn : & mut DbConn ) -> EmptyResult {
async fn _update_revision ( uuid : & str , date : & NaiveDateTime , conn : & mut DbConn ) -> EmptyResult {
db_run ! { conn : {
db_run ! { conn : {
crate ::util ::retry ( | | {
retry ( | | {
diesel ::update ( users ::table . filter ( users ::uuid . eq ( uuid ) ) )
diesel ::update ( users ::table . filter ( users ::uuid . eq ( uuid ) ) )
. set ( users ::updated_at . eq ( date ) )
. set ( users ::updated_at . eq ( date ) )
. execute ( conn )
. execute ( conn )