public static ServerResponse ResetPassword(string emailOrMobile) { ServerResponse response = new ServerResponse(); try { IRandomTextGenerator generator = IocInstance.Container.Resolve <IRandomTextGenerator>(); var newPassword = generator.Generate(RandomChars, RandomLength); ResetPasswordInfo info = new ResetPasswordInfo() { ClientId = CurrentClient.ClientId, SessionId = HttpContext.Current.Session.SessionID, DeviceId = HttpContext.Current.Request.UserHostAddress, DeviceInfo = HttpContext.Current.Request.UserAgent, EmailOrMobile = emailOrMobile, NewPassword = newPassword }; var cp = IocInstance.Container.Resolve <ISSOClientProvider>(); var r = cp.ResetPassword(info); response.Status = r.Status; response.Message = r.Message; } catch (Exception ex) { response.Status = ResponseStatus.Exception; response.Message = ex.Message; } return(response); }
public async Task <IHttpActionResult> ResetPassword(string userName, [FromBody] ResetPasswordInfo resetPassword) { EnsureThatUsersEditable(userName); var result = await _securityService.ResetPasswordAsync(userName, resetPassword.NewPassword); return(ProcessSecurityResult(result)); }
public async Task <IHttpActionResult> ResetPassword(string userName, [FromBody] ResetPasswordInfo resetPassword) { EnsureUserIsEditable(userName); var result = await _securityService.ResetPasswordAsync(userName, resetPassword.NewPassword); return(Content(result.Succeeded ? HttpStatusCode.OK : HttpStatusCode.BadRequest, result)); }
public async Task <ActionResult> ResetPassword(ResetPasswordInfo model) { model.ReconstructSettings(); this.ViewData[ResetPasswordInfo.Key] = model; LoadPage(model.Settings.Uri); var settings = model.Settings; if (settings.UseValidateHuman) { bool IsValidated = model.ValidateHuman.ValidateValue(model.ValidationValue); if (!IsValidated) { ModelState.AddModelError("ValidationValue", model.ValidateHuman.AltValidationFailText); model.ValidationValue = String.Empty; } } if (String.IsNullOrEmpty(settings.UserCode)) { ModelState.AddModelError(String.Empty, "Reset code not provided."); } if (ModelState.IsValid) { string confirmView = settings.PostPartialName; if (!String.IsNullOrEmpty(settings.PostPartialName)) { confirmView = settings.PostPartialConfirmation; } var user = await securityHelper.UserManager.FindByEmailAsync(model.Email); if (user == null) { return(PartialView(confirmView, model)); } else { SecurityData sd = new SecurityData(); var result = sd.ResetPassword(user, settings.UserCode, model.Password); model.CreationResult = result; if (result.Succeeded) { return(PartialView(confirmView, model)); } AddErrors(result); } } Helper.HandleErrorDict(ModelState); return(PartialView(settings.PostPartialName, model)); }
public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo) { Assert.IsNotNull(resetPasswordInfo); Assert.IsStringNotNullOrEmpty(resetPasswordInfo.EmailOrMobile); Assert.IsStringNotNullOrEmpty(resetPasswordInfo.NewPassword); IServerResponse response = serverProvider.ResetPassword(resetPasswordInfo); return(response); }
public async Task <IHttpActionResult> ResetCurrentUserPassword([FromBody] ResetPasswordInfo resetPassword) { var currentUserName = User.Identity.Name; EnsureUserIsEditable(currentUserName); var result = await _securityService.ResetPasswordAsync(currentUserName, resetPassword.NewPassword, resetPassword.ForcePasswordChangeOnFirstLogin); return(Content(result.Succeeded ? HttpStatusCode.OK : HttpStatusCode.BadRequest, result)); }
public ResetPasswordInfo GetDataFromUriCall() { ResetPasswordInfo info = new ResetPasswordInfo(); //var plist = NSUserDefaults.StandardUserDefaults; if (!string.IsNullOrEmpty(NSUserDefaults.StandardUserDefaults.StringForKey("user_id"))) { info.userId = NSUserDefaults.StandardUserDefaults.StringForKey("user_id"); info.token = NSUserDefaults.StandardUserDefaults.StringForKey("token"); info.tokenResetAt = NSUserDefaults.StandardUserDefaults.StringForKey("token_reset_at"); } return(info); }
public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo) { var emailOrMobile = resetPasswordInfo.EmailOrMobile.ToLower(); var obj = repoUser.Query(o => o.Email == emailOrMobile || o.Mobile == emailOrMobile).FirstOrDefault(); ServerResponse <Session> response = new ServerResponse <Session>(); if (obj == null) { response.Status = ResponseStatus.Failed; response.Message = DAF.SSO.Resources.Locale(o => o.EmailOrMobileNotFound); } else { obj.Password = pwdEncryptor.Encrypt(resetPasswordInfo.NewPassword); if (repoUser.Update(obj)) { // reset successfully, sent user info. ResetPasswordMessage msg = new ResetPasswordMessage() { Account = obj.Account, FullName = obj.FullName, NickName = obj.NickName, NewPassword = resetPasswordInfo.NewPassword }; if (resetPasswordInfo.EmailOrMobile == obj.Email) { msg.Email = obj.Email; } else if (resetPasswordInfo.EmailOrMobile == obj.Mobile) { msg.Mobile = obj.Mobile; } if (!string.IsNullOrEmpty(msg.Email) || !string.IsNullOrEmpty(msg.Mobile)) { MessageManager.Publish <ResetPasswordMessage>(msg); } response.Status = ResponseStatus.Success; response.Message = DAF.SSO.Resources.Locale(o => o.ChangePasswordSuccessfully); } else { response.Status = ResponseStatus.Failed; response.Message = DAF.Core.Resources.Locale(o => o.SaveFailure); } } return(response); }
public ResetPasswordInfo GetDataFromUriCall() { ISharedPreferences prefs = Android.App.Application.Context.GetSharedPreferences("PREF_NAME", FileCreationMode.Private); ResetPasswordInfo info = new ResetPasswordInfo(); if (string.IsNullOrEmpty(info.userId)) { info.userId = prefs.GetString("user_id", string.Empty); info.token = prefs.GetString("token", string.Empty); info.tokenResetAt = prefs.GetString("token_reset_at", string.Empty); } return(info); }
public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo) { Assert.IsNotNull(resetPasswordInfo); Assert.IsStringNotNullOrEmpty(resetPasswordInfo.EmailOrMobile); Assert.IsStringNotNullOrEmpty(resetPasswordInfo.NewPassword); IServerResponse response = null; var chanel = CreateChannel(); chanel.Call(p => { response = p.ResetPassword(resetPasswordInfo); }); return(response); }
public object ResetPassword([FromBody] ResetPasswordInfo info) { ResetPasswordResult result = _accountService.ResetPassword(info.Account, info.Password, info.Code); switch (result.Code) { case ResetPasswordCode.AccountWrong: return(new { Code = "accountWrong", Msg = "账号错误" }); case ResetPasswordCode.CodeWrong: return(new { Code = "codeWrong", Msg = "代码错误" }); case ResetPasswordCode.Success: return(new { Code = "success", Msg = "成功" }); default: return(new { Code = "undefined" }); } }
public object GuestResetPassword(ResetPasswordInfo Info) { var userID = this.loggedInUserID(); try { if (!ModelState.IsValid) { throw new FormatException(); } var result = bl_GuestList.ResetPassword(userID, Info.OldPassword, Info.NewPassword); if (result.hasError) { return(new { isSuccess = false, errorText = result.ErrorText }); } else { return(new { isSuccess = true }); } } catch (NullReferenceException e) { return(new { isSuccess = false, errorText = e.Message }); } catch (Exception ex) { return(new { isSuccess = false, errorText = ex.Message }); } return(new { isSuccess = true, errorText = "" }); }
public async Task <IHttpActionResult> ResetPasswordByToken(string userId, [FromBody] ResetPasswordInfo resetPassword) { var result = await _securityService.ResetPasswordAsync(userId, resetPassword.Token, resetPassword.NewPassword); return(ProcessSecurityResult(result)); }
/// <summary> /// Reset password /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="userName"></param> /// <param name="resetPassword">New password.</param> /// <returns>Task of SecurityResult</returns> public async System.Threading.Tasks.Task<SecurityResult> SecurityResetPasswordAsync(string userName, ResetPasswordInfo resetPassword) { ApiResponse<SecurityResult> localVarResponse = await SecurityResetPasswordAsyncWithHttpInfo(userName, resetPassword); return localVarResponse.Data; }
public IServerResponse ResetPassword(ResetPasswordInfo resetPasswordInfo) { return(serverProvider.ResetPassword(resetPasswordInfo)); }
/// <summary> /// Reset password /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="userName"></param> /// <param name="resetPassword">New password.</param> /// <returns>Task of ApiResponse (SecurityResult)</returns> public async System.Threading.Tasks.Task<ApiResponse<SecurityResult>> SecurityResetPasswordAsyncWithHttpInfo(string userName, ResetPasswordInfo resetPassword) { // verify the required parameter 'userName' is set if (userName == null) throw new ApiException(400, "Missing required parameter 'userName' when calling VirtoCommercePlatformApi->SecurityResetPassword"); // verify the required parameter 'resetPassword' is set if (resetPassword == null) throw new ApiException(400, "Missing required parameter 'resetPassword' when calling VirtoCommercePlatformApi->SecurityResetPassword"); var localVarPath = "/api/platform/security/users/{userName}/resetpassword"; var localVarPathParams = new Dictionary<string, string>(); var localVarQueryParams = new Dictionary<string, string>(); var localVarHeaderParams = new Dictionary<string, string>(Configuration.DefaultHeader); var localVarFormParams = new Dictionary<string, string>(); var localVarFileParams = new Dictionary<string, FileParameter>(); object localVarPostBody = null; // to determine the Content-Type header string[] localVarHttpContentTypes = new string[] { "application/json", "text/json", "application/xml", "text/xml", "application/x-www-form-urlencoded" }; string localVarHttpContentType = ApiClient.SelectHeaderContentType(localVarHttpContentTypes); // to determine the Accept header string[] localVarHttpHeaderAccepts = new string[] { "application/json", "text/json", "application/xml", "text/xml" }; string localVarHttpHeaderAccept = ApiClient.SelectHeaderAccept(localVarHttpHeaderAccepts); if (localVarHttpHeaderAccept != null) localVarHeaderParams.Add("Accept", localVarHttpHeaderAccept); // set "format" to json by default // e.g. /pet/{petId}.{format} becomes /pet/{petId}.json localVarPathParams.Add("format", "json"); if (userName != null) localVarPathParams.Add("userName", ApiClient.ParameterToString(userName)); // path parameter if (resetPassword.GetType() != typeof(byte[])) { localVarPostBody = ApiClient.Serialize(resetPassword); // http body (model) parameter } else { localVarPostBody = resetPassword; // byte array } // make the HTTP request IRestResponse localVarResponse = (IRestResponse)await ApiClient.CallApiAsync(localVarPath, Method.POST, localVarQueryParams, localVarPostBody, localVarHeaderParams, localVarFormParams, localVarFileParams, localVarPathParams, localVarHttpContentType); int localVarStatusCode = (int)localVarResponse.StatusCode; if (localVarStatusCode >= 400 && (localVarStatusCode != 404 || Configuration.ThrowExceptionWhenStatusCodeIs404)) throw new ApiException(localVarStatusCode, "Error calling SecurityResetPassword: "******"Error calling SecurityResetPassword: " + localVarResponse.ErrorMessage, localVarResponse.ErrorMessage); return new ApiResponse<SecurityResult>(localVarStatusCode, localVarResponse.Headers.ToDictionary(x => x.Name, x => x.Value.ToString()), (SecurityResult)ApiClient.Deserialize(localVarResponse, typeof(SecurityResult))); }
public async Task <IHttpActionResult> ResetPasswordByToken(string userId, [FromBody] ResetPasswordInfo resetPassword) { var result = await _securityService.ResetPasswordAsync(userId, resetPassword.Token, resetPassword.NewPassword); return(Content(result.Succeeded ? HttpStatusCode.OK : HttpStatusCode.BadRequest, result)); }
/// <summary> /// Reset password /// </summary> /// <exception cref="VirtoCommerce.Platform.Client.Client.ApiException">Thrown when fails to make API call</exception> /// <param name="userName"></param> /// <param name="resetPassword">New password.</param> /// <returns>SecurityResult</returns> public SecurityResult SecurityResetPassword(string userName, ResetPasswordInfo resetPassword) { ApiResponse<SecurityResult> localVarResponse = SecurityResetPasswordWithHttpInfo(userName, resetPassword); return localVarResponse.Data; }