public ValidationResult Validate(EmailValidationKeyProvider provider, AuthContext authContext, TenantManager tenantManager, UserManager userManager, AuthManager authentication) { ValidationResult checkKeyResult; switch (Type) { case ConfirmType.EmpInvite: checkKeyResult = provider.ValidateEmailKey(Email + Type + (int)EmplType, Key, provider.ValidInterval); break; case ConfirmType.LinkInvite: checkKeyResult = provider.ValidateEmailKey(Type.ToString() + (int)EmplType, Key, provider.ValidInterval); break; case ConfirmType.PortalOwnerChange: checkKeyResult = provider.ValidateEmailKey(Email + Type + UiD.HasValue, Key, provider.ValidInterval); break; case ConfirmType.EmailChange: checkKeyResult = provider.ValidateEmailKey(Email + Type + authContext.CurrentAccount.ID, Key, provider.ValidInterval); break; case ConfirmType.PasswordChange: var hash = string.Empty; if (P == 1) { var tenantId = tenantManager.GetCurrentTenant().TenantId; hash = authentication.GetUserPasswordHash(tenantId, UiD.Value); } checkKeyResult = provider.ValidateEmailKey(Email + Type + (string.IsNullOrEmpty(hash) ? string.Empty : Hasher.Base64Hash(hash)) + UiD, Key, provider.ValidInterval); break; case ConfirmType.Activation: checkKeyResult = provider.ValidateEmailKey(Email + Type + UiD, Key, provider.ValidInterval); break; case ConfirmType.ProfileRemove: // validate UiD if (P == 1) { var user = userManager.GetUsers(UiD.GetValueOrDefault()); if (user == null || user.Status == EmployeeStatus.Terminated || authContext.IsAuthenticated && authContext.CurrentAccount.ID != UiD) { return(ValidationResult.Invalid); } } checkKeyResult = provider.ValidateEmailKey(Email + Type + UiD, Key, provider.ValidInterval); break; default: checkKeyResult = provider.ValidateEmailKey(Email + Type, Key, provider.ValidInterval); break; } return(checkKeyResult); }