Пример #1
0
        public LoginUserInformation Login(string userName, string password)
        {
            SystemUser systemUser;

            try
            {
                var systemUserGroup = _systemUserRepository.GetAll();
                systemUser = systemUserGroup.Single(x => x.LoginName == userName);
            }
            catch
            {
                throw new Exception("用户名不存在");
            }
            if (!PasswordHasher.ValidateHash(password, systemUser.Password))
            {
                throw new Exception("登陆密码错误");
            }
            systemUser.LastLoginDate = _currentTimeProvider.CurrentTime();
            systemUser.IsLogin       = Enums.IsLogin.Logining;
            _systemUserRepository.Update(systemUser);
            var loginUserInfo = new LoginUserInformation
            {
                SystemUserId = systemUser.Id,
                LoginName    = systemUser.LoginName
            };

            return(loginUserInfo);
        }
Пример #2
0
        public LoginUserInformation GetLoginUserInformationById(int sysUserId)
        {
            var systemUser    = _systemUserRepository.Get(sysUserId);
            var loginUserInfo = new LoginUserInformation
            {
                LoginName    = systemUser.LoginName,
                SystemUserId = systemUser.Id
            };

            return(loginUserInfo);
        }