public async Task <ActionResult> ChangeEmail(string userId) { var model = new VerifyEMailModel(); if (userId == null) { model.Message = "Ungültiger Link"; return(View("ChangeEMailError", model)); } // Expiry Date entfernen, Bemerkung entfernen var user = await UserManager.FindByIdAsync(userId); if (user == null) { model.Message = "Ungültiger Link"; return(View("ChangeEMailError", model)); } user.UserName = user.Remark; user.Email = user.Remark; user.ExpiryDate = null; user.Remark = string.Empty; user.Submitted = null; await UserManager.UpdateAsync(user); return(View("ChangeEMailSuccess", model)); }
public async Task <ActionResult> ConfirmHmEmail(string userId, string code) { var model = new VerifyEMailModel(); if (userId == null || code == null) { model.Message = "Ungültiger Link"; return(View("VerifyEMailError", model)); } var user = await UserManager.FindByIdAsync(userId); if (user != null) { user.MemberState = MemberState.Student; await UserManager.UpdateAsync(user); return(View("VerifyEMailSuccess", model)); } model.Message = "Unbekannter Benutzer"; return(View("VerifyEMailError", model)); }
public async Task <ActionResult> ConfirmEmail(string userId, string code) { var model = new VerifyEMailModel(); if (userId == null || code == null) { model.Message = "Ungültiger Link"; return(View("VerifyEMailError", model)); } var result = await UserManager.ConfirmEmailAsync(userId, code); if (result.Succeeded) { // Expiry Date entfernen, Bemerkung entfernen var user = await UserManager.FindByIdAsync(userId); if (user != null) { user.ExpiryDate = null; user.Remark = string.Empty; user.Submitted = null; await UserManager.UpdateAsync(user); } return(View("VerifyEMailSuccess", model)); } else { model.Message = ""; foreach (var error in result.Errors) { model.Message += error + ", "; } return(View("VerifyEMailError", model)); } }