public ActionResult ConfirmEmailAndCreatePassword(string userId, string code) { if (userId == null || code == null) { return(View("Error")); } var vm = new ConfirmEmailAndCreatePasswordViewModel() { UserId = userId, ConfirmationCode = code }; return(View(vm)); }
public async Task <ActionResult> ConfirmEmailAndCreatePassword(ConfirmEmailAndCreatePasswordViewModel vm) { try { if (!ModelState.IsValid) { this.Response.StatusCode = (int)HttpStatusCode.BadRequest; return(this.JsonNet(this.ModelState.AsModelErrorCollection())); } var result = await UserManager.ConfirmEmailAsync(vm.UserId, vm.ConfirmationCode); if (!result.Succeeded) { AddErrors(result); this.Response.StatusCode = (int)HttpStatusCode.BadRequest; return(this.JsonNet(this.ModelState.AsModelErrorCollection())); } result = await UserManager.AddPasswordAsync(vm.UserId, vm.Password); if (!result.Succeeded) { AddErrors(result); this.Response.StatusCode = (int)HttpStatusCode.BadRequest; return(this.JsonNet(this.ModelState.AsModelErrorCollection())); } return(this.JsonNet(new { Ok = true })); } catch (Exception ex) { this.Response.StatusCode = (int)HttpStatusCode.InternalServerError; return(this.JsonNet(ex.AsModelErrorCollection())); } }