Ejemplo n.º 1
0
        private ContactMessageViewModel InternalGetContactMessageViewModel(string username)
        {
            var viewModel = new ContactMessageViewModel();

            if (!string.IsNullOrWhiteSpace(username))
            {
                try
                {
                    var provider = _providerUserProvider.GetProviderUser(username);
                    viewModel.Name  = provider.Fullname;
                    viewModel.Email = provider.Email;
                }
                catch (Exception ex)
                {
                    _logService.Error("Failed to created view model (ignoring)", ex);
                }
            }
            return(viewModel);
        }
Ejemplo n.º 2
0
        public MediatorResponse VerifyEmailAddress(string username, VerifyEmailViewModel verifyEmailViewModel)
        {
            var result = _verifyEmailViewModelValidator.Validate(verifyEmailViewModel);

            if (!result.IsValid)
            {
                return(GetMediatorResponse(ProviderUserMediatorCodes.VerifyEmailAddress.FailedValidation, verifyEmailViewModel, result));
            }

            if (!_providerUserProvider.ValidateEmailVerificationCode(username, verifyEmailViewModel.VerificationCode))
            {
                return(GetMediatorResponse(ProviderUserMediatorCodes.VerifyEmailAddress.InvalidCode, VerifyEmailViewModelMessages.VerificationCodeEmailIncorrectMessage, UserMessageLevel.Error));
            }

            var user     = _providerUserProvider.GetProviderUser(username);
            var provider = _providerProvider.GetProviderViewModel(user.ProviderId);

            if (!provider.IsMigrated)
            {
                return(GetMediatorResponse(ProviderUserMediatorCodes.VerifyEmailAddress.OkNotYetMigrated));
            }

            return(GetMediatorResponse(ProviderUserMediatorCodes.VerifyEmailAddress.Ok));
        }