コード例 #1
0
        public async Task <PostResponseModel> ConfirmRegistration(int vendorId)
        {
            PostResponseModel postResponseModel = new PostResponseModel();

            var passwordSalt      = AuthenticateUtility.CreatePasswordSalt();
            var password          = AuthenticateUtility.GetRandomAlphanumericString(12);
            var encryptedPassword = AuthenticateUtility.GeneratePassword(password, passwordSalt);

            var registerVendorResponse = await _vendorRepository.ConfirmRegistration(vendorId, encryptedPassword, passwordSalt);

            postResponseModel.IsAlreadyExists = registerVendorResponse.IsUserExists;
            if (!postResponseModel.IsAlreadyExists && registerVendorResponse.Success)
            {
                var emailBody    = "Your password: "******"Confirm Your Registration";

                var emailResponse = await _messageSenderUtility.SendEmail(emailBody, emailSubject, registerVendorResponse.Content.VendorEmail);

                postResponseModel.Success = emailResponse.IsEmailSend;

                //Log email
                EmailLogs emailLogDetails = new EmailLogs()
                {
                    FromEmailAddress = emailResponse.FromEmailAddress,
                    ToEmailAddress   = emailResponse.ToEmailAddress,
                    Subject          = emailSubject,
                    Body             = emailBody,
                    IsProduction     = emailResponse.IsProductionEnvironment,
                    IsSend           = emailResponse.IsEmailSend,
                    ApplicationId    = (int)ApplicationType.Admin,
                    FromUserType     = "System",
                    ToUserType       = "Vendor",
                    ToUserId         = registerVendorResponse.Content.VendorId,
                    CreatedDate      = DateTime.Now
                };

                await _loggingRepository.LogEmailTransaction(emailLogDetails);
            }
            else
            {
                postResponseModel.Success = registerVendorResponse.Success;
            }

            return(postResponseModel);
        }
コード例 #2
0
        public async Task <GetResponseModel> Authenticate(string UserName, string Password, int[] UserType)
        {
            GetResponseModel getResponseModel = new GetResponseModel();

            var userDetails = await _authenticateRepository.GetUserDetails(x => x.Username == UserName && UserType.Contains(x.UserType));

            if (userDetails == null && userDetails.Password != AuthenticateUtility.GeneratePassword(Password, userDetails.PasswordSalt))
            {
                getResponseModel.NoContent = true;
            }
            else
            {
                AuthenticateResponse authenticateResponse = new AuthenticateResponse()
                {
                    Token        = GenerateJwtToken(userDetails),
                    RefreshToken = GenerateRefreshToken("")
                };
                getResponseModel.Content = authenticateResponse;
            }
            getResponseModel.Success = true;
            return(getResponseModel);
        }