public async Task <IHttpActionResult> ConfirmEmail(ConfirmEmalViewModel model) { try { var user = await _auth.AccountGetAsync(model.UserId); if (object.Equals(user, null)) { return(AccountNotFound()); } var result = await _auth.AccountConfirmEmailAsync(user.Id); var errorResult = GetErrorResult(result); if (!object.Equals(errorResult, null)) { return(errorResult); } if (model.IsBusiness()) { await _auth.AccountMaskAsBusinessAsync(user); } await _auth.AccountActivateAsync(user); } catch (Exception exc) { return(Request.HttpExceptionResult(exc)); } return(Ok()); }
public async Task <IHttpActionResult> ConfirmEmail(ConfirmEmalViewModel model) { try { var account = await _auth.AccountGetAsync(model.UserId); if (object.Equals(account, null)) { return(AccountNotFound()); } model.Token = HttpUtility.UrlDecode(model.Token); IdentityResult result = null; if (string.IsNullOrEmpty(model.Token)) //such bad solution, but saves a lot of time { result = await _auth.AccountConfirmEmailAsync(account.Id); } else { result = await _auth.AccountConfirmEmailAsync(account.Id, model.Token); } var errorResult = GetErrorResult(result); if (!object.Equals(errorResult, null)) { return(errorResult); } if (model.IsBusiness()) { await _auth.AccountMaskAsBusinessAsync(account); } await _auth.AccountActivateAsync(account); await _auth.AccountVisitorIdSetAsync(account, model.VisitorId); var internalSignInViewModel = new SignInViewModel(account); return(ResponseMessage(await OauthManager.InternalSignIn(internalSignInViewModel))); } catch (Exception exc) { return(Request.HttpExceptionResult(exc)); } }