1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-06-21 00:45:18 +00:00

Can generate a reset token if password is valid

This commit is contained in:
2020-07-13 14:20:28 +02:00
parent d33e1fe77c
commit e4b361ab12
5 changed files with 63 additions and 1 deletions

View File

@ -114,6 +114,19 @@ pub fn destroy_all_user_tokens(id: &UserID) -> ResultBoxError {
.exec()
}
/// Generate a new password reset token
pub fn generate_password_reset_token(user_id: &UserID) -> ResultBoxError<String> {
let token = rand_str(255);
database::UpdateInfo::new(USERS_TABLE)
.cond_user_id("ID", user_id)
.set_str("password_reset_token", &token)
.set_u64("password_reset_token_time_create", time())
.exec()?;
Ok(token)
}
/// Check out whether a virtual directory is taken by a user or not
pub fn check_user_directory_availability(dir: &str, user_id: Option<UserID>) -> ResultBoxError<bool> {
let found_user = user_helper::find_user_by_virtual_directory(dir);