pub fn verify_reset_password(&self, admin_id: ID, token: &str) -> Result<()> {
        use crate::schema::reset_password_admins::dsl;

        let reset_password: ResetPasswordAdmin = dsl::reset_password_admins.find(admin_id).first(self.db)?;
        let now = util::now().timestamp();

        match (reset_password.expiration, reset_password.token) {
            (Some(expiration), old_token) => {
                let exp = expiration.timestamp();
                if exp < now {
                    Err(PdmError::BadRequest(
                        ErrorCode::InvalidParameter as i32,
                        "Token has expired".to_string(),
                    ))?
                } else if old_token != token {
                    Err(PdmError::InvalidParameter("Mismatch token".to_string()))
                } else {
                    Ok(())
                }
            }
            _ => Err(PdmError::NotFound("Token not found".to_string()))?,
        }
    }
/// Verifikasi token untuk reset password.
Verifikasi token untuk reset password.
Verifikasi token untuk reset password .
pub fn verify_reset_password(&self, admin_id: ID, token: &str) -> Result<()> {
        use crate::schema::reset_password_admins::dsl;
        let reset_password: ResetPasswordAdmin = dsl::reset_password_admins.find(admin_id).first(self.db)?;
        let now = util::now().timestamp();
        match (reset_password.expiration, reset_password.token) {
            (Some(expiration), old_token) => {
                let exp = expiration.timestamp();
                if exp < now {
                    Err(PdmError::BadRequest(
                        ErrorCode::InvalidParameter as i32,
                        "Token has expired".to_string(),
                    ))?
                } else if old_token != token {
                    Err(PdmError::InvalidParameter("Mismatch token".to_string()))
                } else {
                    Ok(())
                }
            }
            _ => Err(PdmError::NotFound("Token not found".to_string()))?,
        }
    }
pub fn verify_reset_password ( & self , admin_id : ID , token : & str ) -> Result < ( ) > { use crate :: schema :: reset_password_admins :: dsl ; let reset_password : ResetPasswordAdmin = dsl :: reset_password_admins . find ( admin_id ) . first ( self . db ) ? ; let now = util :: now ( ) . timestamp ( ) ; match ( reset_password . expiration , reset_password . token ) { ( Some ( expiration ) , old_token ) => { let exp = expiration . timestamp ( ) ; if exp < now { Err ( PdmError :: BadRequest ( ErrorCode :: InvalidParameter as i32 , " " . to_string ( ) , ) ) ? } else if old_token != token { Err ( PdmError :: InvalidParameter ( " " . to_string ( ) ) ) } else { Ok ( ( ) ) } } _ => Err ( PdmError :: NotFound ( " " . to_string ( ) ) ) ? , } }
Verifikasi token untuk reset password.
Verifikasi token untuk reset password .
&self
admin_id
ID
token
&str
&self
admin_id
ID
token
&str