예제 #1
0
        public CheckLoginResponse CheckLogin(CheckLoginRequest request)
        {
            return Execute(_repository, r =>
            {
                request.Email = request.Email.ToStr().Trim().ToLower();
                var response = new CheckLoginResponse
                {
                    BeUser = _cacheHelper.GetAllBeUsers().FirstOrDefault(i => i.Email == request.Email)
                };

                if (response.BeUser == null)
                {
                    response.Messages.Add("UnableFindUser");//Return resouce key
                    return response;
                }

                if (!SimpleHash.VerifyHash(request.Password, SiteSettings.HashAlgorithm, response.BeUser.HashPassword))
                {
                    response.Messages.Add("PwdIncorrect");
                    return response;
                }

                if (response.BeUser.Status == BeUserStatus.Locked)
                {
                    response.Messages.Add("UserLocked");
                    return response;
                }

                r.UpdateUserLogin(new UpdateUserLoginRequest
                {
                    UserId = response.BeUser.Id
                });

                response.EntityId = response.BeUser.Id;

                return response;
            });
        }