public IActionResult UpdatePassword([FromBody] NewPasswordObject input) { //fetch user var user = this.GetClient(dataContext); //ensure password if (user == null || !PasswordHash.FromBase64(user.PasswordHash).Verify(input.OldPassword)) { return(BadRequest()); } //create new user.PasswordHash = new PasswordHash(input.NewPassword).ToBase64(); dataContext.Update(user); return(Ok()); }
public async Task <IActionResult> PasswordChange( [FromHeader] string jwttoken, [FromBody] NewPasswordObject newpassword) { // Permission Level User if (this.jwtService.PermissionLevelValid(jwttoken, "user")) { try { var response = await this.firebase.PasswordChange(newpassword.Email, newpassword.OldPassword, newpassword.NewPassword); if (string.IsNullOrWhiteSpace(response)) { return(this.Conflict()); } else if (response == "302") { return(new StatusCodeResult(StatusCodes.Status226IMUsed)); } else { return(this.Ok(response)); } } catch (FirebaseAuthException) { return(this.BadRequest()); } catch (AggregateException) { return(this.BadRequest()); } } return(this.Unauthorized()); }