Пример #1
0
        /// <summary>
        /// Passwords the sign in asynchronous.
        /// </summary>
        /// <param name="userName">Name of the user.</param>
        /// <param name="password">The password.</param>
        /// <param name="rememberMe">if set to <c>true</c> [remember me].</param>
        /// <param name="lockoutOnFailure">if set to <c>true</c> [lockout on failure].</param>
        /// <returns>
        /// Application User
        /// </returns>
        public async Task <IApplicationUser> PasswordSignInAsync(string userName, string password, bool rememberMe = false, bool lockoutOnFailure = false)
        {
            var user = await _userRepository.FindByUserName(userName);

            if (user.IsNull())
            {
                return(null);
            }

            if (!await this._securityManager.VerifyHashedPassword(user.PasswordHash, password))
            {
                return(null);
            }

            var email = await _userEmailsRepository.GetCurrentActiveEmailAsync(user.Id);

            return(new ApplicationUser
            {
                UserId = user.Id,
                FirstName = user.FirstName,
                LastName = user.LastName,
                Gender = user.Gender,
                IsCastingProfessional = user.IsCastingProfessional,
                Designation = user.Designation,
                OrgName = user.OrgName,
                OrgWebsite = user.OrgWebsite,
                UserName = user.UserName,
                Email = email?.Email ?? string.Empty,
                IsEmailVerified = email?.EmailConfirmed ?? false,
                SecurityStamp = user.SecurityStamp
            });
        }
Пример #2
0
        public async Task <AppUserDetail> GetUserDetails(Guid userId)
        {
            var appUserTask = _userRepository.FindByIdAsync(userId);
            var addressTask = _addressRepository.GetAsync(userId);
            var emalTask    = _userEmailsRepository.GetCurrentActiveEmailAsync(userId);
            var phoneTask   = _userPhonesRepository.GetUserPhoneDetailByUserId(userId);
            var detailTask  = _userDetailRepository.GetUserDetailByUserId(userId);

            var taskResult = Task.WhenAll(appUserTask, addressTask, emalTask, phoneTask, detailTask);

            try
            {
                await taskResult.ConfigureAwait(false);

                if (taskResult.IsCompletedSuccessfully)
                {
                    return(new AppUserDetail
                    {
                        ApplicationUser = _mapper.Map <AppUserDto>(await appUserTask),
                        CurrentAddress = _mapper.Map <AddressDto>(await addressTask),
                        UserDetails = _mapper.Map <UserDetailDto>(await detailTask),
                        Email = _mapper.Map <EmailDto>(await emalTask),
                        Phone = _mapper.Map <PhoneDto>(await phoneTask)
                    });
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }

            return(null);
        }
Пример #3
0
        /// <summary>
        /// Finds the by user name.
        /// </summary>
        /// <param name="userName">user name</param>
        /// <returns>
        /// User data object
        /// </returns>
        public async Task <IUser> FindByUserName(string userName)
        {
            var userObj = await FindSingleAsync("SELECT * FROM Users WHERE UserName=@UserName", new { UserName = userName }).ConfigureAwait(false);

            if (userObj.IsNotNull())
            {
                var emailObj = await _userEmailsRepository.GetCurrentActiveEmailAsync(userObj.Id).ConfigureAwait(false);

                if (emailObj.IsNotNull())
                {
                    userObj.Email = emailObj.Email;
                }
            }

            return(userObj);
        }