/// <summary> /// Retrieves form. /// </summary> /// <param name="context">Form context.</param> /// <returns>View model used to render form.</returns> public Form GetForm(string context) { // Construct form Form form = new Form { Fields = new Dictionary <string, IFormField>(), CustomErrorMessages = new List <string>(), Id = FormId.ToString(), Context = context }; try { // Get website identifier long tenantId = _authenticationService.TenantId; // Confirm user ConfirmUserModel model = new ConfirmUserModel { ConfirmKey = context, TenantId = tenantId }; _authenticationService.ConfirmUser(model); } catch (ValidationErrorException ex) { foreach (ValidationError error in ex.Errors) { form.CustomErrorMessages.Add(error.Message); } } // Return result return(form); }
public void ConfirmUser(ConfirmUserModel model) { // Validate supplied confirmation details _authenticationValidator.ValidateConfirmUser(model); // Get user Token token = _securityService.DeserializeToken(model.ConfirmKey); User user = _userRepository.ReadUserByConfirmToken(model.TenantId, token); // Flag user as confirmed user.Confirmed = true; user.ConfirmTokenValue = null; user.ConfirmTokenExpiry = null; // Update user in database _userRepository.UpdateUser(user); }
/// <summary> /// Performs main validation of supplied user confirmation details. /// </summary> /// <param name="model">Confirm user details.</param> /// <param name="keyPrefix">Validation key prefix.</param> public void ValidateConfirmUser(ConfirmUserModel model, string keyPrefix = null) { ValidateConfirmUserStatus(new ConfirmUserStatusModel { TenantId = model.TenantId, SetPassword = false, ConfirmKey = model.ConfirmKey }, keyPrefix); }