public void rpc_reset_password(String username, String email) { var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient); if (this.FromHostId == toHostId) { var protoCode = ProtocolCode.RESET_PASSWORD_REQ; if (protoCode < OpCode.CALL_ACTOR_METHOD) { var peer = Global.NetManager.GetPeerById(this.FromHostId, this.NetType); var context = new RpcContext(null, peer); Global.Host.CallMethodWithParams(protoCode, new object[] { username, email, context }); } else { Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { username, email }); } return; } var msg = new ResetPasswordReq() { username = username, email = email }; this.CallRemoteMethod(ProtocolCode.RESET_PASSWORD_REQ, msg, null); }
public override async Task <ResetPasswordResp> ResetPassword(ResetPasswordReq request, ServerCallContext context) { var options = request.Options; var user = context.GetHttpContext().User; if (!await _authorizationProvider.CheckAccessAsync(user, ResetOperation, context.CancellationToken).ConfigureAwait(false)) { throw RpcExceptions.AccessDenied(); } var resetPasswordSource = new TaskCompletionSource <bool>(); var envelope = new CallbackEnvelope(OnMessage); _publisher.Publish( new UserManagementMessage.ResetPassword(envelope, user, options.LoginName, options.NewPassword)); await resetPasswordSource.Task.ConfigureAwait(false); return(new ResetPasswordResp()); void OnMessage(Message message) { if (HandleErrors(options.LoginName, message, resetPasswordSource)) { return; } resetPasswordSource.TrySetResult(true); } }
public override async Task <ResetPasswordResp> ResetPassword(ResetPasswordReq request, ServerCallContext context) { var options = request.Options; var user = await GetUser(_authenticationProvider, context.RequestHeaders).ConfigureAwait(false); var resetPasswordSource = new TaskCompletionSource <bool>(); var envelope = new CallbackEnvelope(OnMessage); _queue.Publish( new UserManagementMessage.ResetPassword(envelope, user, options.LoginName, options.NewPassword)); await resetPasswordSource.Task.ConfigureAwait(false); return(new ResetPasswordResp()); void OnMessage(Message message) { if (HandleErrors(options.LoginName, message, resetPasswordSource)) { return; } resetPasswordSource.TrySetResult(true); } }
public async Task <IActionResult> ResetPassword([FromBody] ResetPasswordReq input) { if (!ModelState.IsValid) { return(BadRequest(new Response { Success = false, ErrorMessage = "The details provided are not complete." })); } if (input.Password != input.ConfirmPassword) { return(BadRequest("Password and Confirmed password must be identical")); } if (!PasswordStrength.CheckPasswordComplexity(input.Password)) { return(BadRequest("Password not strong enough.")); } input.Token = System.Net.WebUtility.UrlDecode(input.Token); if (await _loginService.ResetPasswordAsync(input)) { return(Ok(new Response { Success = true })); } return(StatusCode(500, new Response { Success = false, ErrorMessage = "Something went wrong while trying to reset your password." })); }
// Token: 0x06000390 RID: 912 RVA: 0x00007930 File Offset: 0x00005B30 public SDKCommonResp ResetPassword(ResetPasswordReq req) { SDKCommonResp sdkcommonResp = new SDKCommonResp(); string text = RestClientUtil.sendRequest("POST", "/service/users/password/reset", req, this.bean, "ResetPassword"); UserResource.log.Info("ResetPassword result : " + text); return(JsonConvert.DeserializeObject <SDKCommonResp>(text)); }
public BaseItemRes <bool> ResetPassword([FromBody] ResetPasswordReq req) { var reqIn = new UpdatePasswordReq(); reqIn.LoginName = req.LoginName; reqIn.Password = AccConfig.Consul.DefaultPassword; return(this.userBLL.UpdatePassword(reqIn, this.CurUser)); }
/// <summary> /// 重置密码 /// </summary> /// <param name="req"></param> /// <returns></returns> public virtual JsonResult ResetPassword(ResetPasswordReq req) { if (string.IsNullOrEmpty(req.phone)) { return(ResultUtils.Fail("手机号码或用户名不能为空")); } if (string.IsNullOrEmpty(req.code)) { return(ResultUtils.Fail("验证码不能为空")); } if (string.IsNullOrEmpty(req.password)) { return(ResultUtils.Fail("密码不能为空")); } SubmitCodeReq mod = new SubmitCodeReq() { phone = req.phone, code = req.code }; int ret = NH.Service.VerifyService.Instance().SubmitCode(mod); if (ret == 0) { return(ResultUtils.Success("验证码过期")); } else if (ret == -1) { return(ResultUtils.Fail("用户不存在")); } else if (ret == -2) { return(ResultUtils.Fail("手机号码未注册")); } userid = NH.Service.Api.AuthService.GetInstance().ResetPassword(req); if (userid > 0) { Entity.Model.Token token = base.GetToken(); return(ResultUtils.Success(new { userId = token.UserID, timeStamp = token.Timestamp, platform = token.Platform, token = token.TokenStr })); } return(ResultUtils.Fail("重置密码失败")); }
/// <summary> /// 重置密码 /// </summary> /// <param name="req"></param> /// <returns></returns> public virtual int ResetPassword(ResetPasswordReq req) { ISession Session = null; ITransaction transaction = null; try { Session = DBHelper.SessionFactory.OpenSession(); transaction = Session.BeginTransaction(); var query = Session.QueryOver <Users>(); query.Where(c => c.Phone == req.phone && c.IsLocked == false); //query.RootCriteria.AddOrder(Order.Desc("ID")).List<AuthVerify>(); Users mod = null; if (query.RowCount() > 1) { mod = query.List().FirstOrDefault(); } else { mod = query.SingleOrDefault(); } if (mod != null && mod.ID > 0) { mod.Password = Encrypt.MD5(req.password); //MD5加密 Session.Update(mod); transaction.Commit(); if (mod != null && mod.ID > 0) { return(mod.ID); } } return(0); } catch (Exception ex) { transaction.Rollback(); LogHelper.WriteLog("重置密码出错:" + ex.Message, "excep_AuthDao.txt"); return(0); } finally { Session.Close(); Session.Dispose(); } }
// TODO: Apply throttling public IHttpActionResult ResetPassword(ResetPasswordReq resetPasswordDto) { var user = AppUserManager.FindByEmail(resetPasswordDto.Email); if (user == null) { // Don't reveal that the user does not exist return(BadRequest()); } var token = HttpUtility.UrlDecode(resetPasswordDto.PasswordResetToken); var identityResult = AppUserManager.ResetPassword(user.Id, token, resetPasswordDto.NewPassword); if (identityResult.Succeeded) { var response = new BaseResponseDto(); response.Message = Responses.ResetPasswordResponseMessage; return(Ok(response)); } return(BadRequestWithIdentityErrors(identityResult)); }
public async Task <bool> ResetPasswordAsync(ResetPasswordReq input) { try { var user = await _userManager.FindByEmailAsync(input.Email); if (user.EmailConfirmed != true) { throw new Exception("The email address submitted is not confirmed."); } var result = await _userManager.ResetPasswordAsync(user, input.Token, input.Password); if (result.Succeeded) { return(true); } throw new Exception(result.ToString()); } catch (Exception e) { throw new Exception(e.Message); } }
/// <summary> /// 重置密码 /// </summary> /// <param name="req"></param> /// <returns></returns> public virtual int ResetPassword(ResetPasswordReq req) { return(dao.ResetPassword(req)); }