public async Task <IHttpActionResult> ResetPassword(ResetPasswordViewModel model) { try { var user = await _auth.AccountGetAsync(model.UserId); if (object.Equals(user, null)) { return(AccountNotFound()); } IdentityResult result = null; if (string.IsNullOrEmpty(model.Token) && user.IsEmptyPassword()) { result = await _auth.AccountPasswordSetAsync(user, model.NewPassword); } else { model.Token = HttpUtility.UrlDecode(model.Token); result = await _auth.AccountResetPasswordAsync(model.UserId, model.Token, model.NewPassword); } var errorResult = GetErrorResult(result); if (!object.Equals(errorResult, null)) { return(errorResult); } if (user.IsEmptyPassword()) { await NotificationManager.AccountCreationComplete(user); } if (!string.IsNullOrEmpty(model.FirstName) || !string.IsNullOrEmpty(model.LastName)) { user = await _auth.AccountGetAsync(model.UserId); user.FirstName = string.IsNullOrEmpty(model.FirstName) ? user.FirstName : model.FirstName; user.LastName = string.IsNullOrEmpty(model.LastName) ? user.LastName : model.LastName; await _auth.AccountUpdateAsync(user); } await _auth.AccountActivateAsync(user); await _auth.AccountVisitorIdSetAsync(user, model.VisitorId); user = await _auth.AccountGetAsync(model.UserId); var internalSignInViewModel = new SignInViewModel(user); return(ResponseMessage(await OauthManager.InternalSignIn(internalSignInViewModel))); } catch (Exception exc) { return(Request.HttpExceptionResult(exc)); } }
private async Task <IHttpActionResult> _register(RegisterViewModel model, Account account, ViewAccountDetails accountDetails, string stackTrace) { if (!object.Equals(account, null)) { await _auth.AccountVisitorIdSetAsync(account, model.VisitorId); if (model.IsBusiness()) { await _auth.AccountMaskAsBusinessAsync(account); //make sure that user will get b2b 30 trial await _auth.AccountActivateAsync(account); } if (account.IsBusiness && string.Equals(model.Source, "sodapdf.com-get-trial", StringComparison.InvariantCultureIgnoreCase)) { await NotificationManager.BusinessDownload(account); } if (account.IsEmptyPassword()) { if (!string.IsNullOrEmpty(model.Password)) { await _auth.AccountPasswordSetAsync(account, model.Password); await NotificationManager.AccountCreationComplete(account); } accountDetails.GeoIp = IpAddressDetector.IpAddress; accountDetails.Id = account.Id; await _auth.AccountDetailsSetAsync(accountDetails); return(Ok()); } return(AccountExists()); } account = new Account(model.Email, model.FirstName, model.LastName); account.IsBusiness = model.IsBusiness(); var result = await _auth.AccountCreateAsync(account, model.Password); var errorResult = GetErrorResult(result); if (!object.Equals(errorResult, null)) { return(errorResult); } accountDetails.GeoIp = IpAddressDetector.IpAddress; accountDetails.Id = account.Id; accountDetails.Source = model.Source; accountDetails.WebForm = FormIdBuilder.Build(model.FormId); await _auth.AccountOptinSetAsync(account, model.Optin); await _auth.AccountDetailsSetAsync(accountDetails); await _auth.AccountVisitorIdSetAsync(account, model.VisitorId); OauthLogger.CreateAccountWarn(Request, account, accountDetails, stackTrace); if ("sodapdf.com-esign-lite".Equals(model.Source, StringComparison.InvariantCultureIgnoreCase)) { return(Ok()); // } if (account.IsBusiness && "sodapdf.com-get-trial".Equals(model.Source, StringComparison.InvariantCultureIgnoreCase)) { await NotificationManager.BusinessDownloadNewAccount(account); } else { if (!string.IsNullOrEmpty(model.Password)) { #if PdfForge if (!object.Equals(accountDetails, null) && "covermount".Equals(accountDetails.Build, StringComparison.InvariantCultureIgnoreCase)) { await NotificationManager.EmailConfirmationCovermount(account); return(Ok()); } #endif await NotificationManager.EmailConfirmation(account); } else { if ("sodapdf.com-opdfs".Equals(model.Source, StringComparison.InvariantCultureIgnoreCase) || "sodapdf.com-opdfs-send-to-email".Equals(model.Source, StringComparison.InvariantCultureIgnoreCase)) { await NotificationManager.MicrotransactionCreatePassword(account); } } } return(Ok()); }