Beispiel #1
0
 private void UpdateUserCookie(long userId)
 {
     //如果编辑的是当前登录用户,才更新COOKIE
     if (userId == GetCurrentUser().Id)
     {
         CookieHelper.RemoveCookie(userKey);
         CookieHelper.WriteEncryptCookie(userKey, JsonConvert.SerializeObject(userRepository.Find(x => x.Id == userId).FirstOrDefault().ToModel <UserDto>()), DateTime.Now);
     }
 }
Beispiel #2
0
        public void CustomerLogin(string userName, string password)
        {
            string md5Password = MD5Helper.MD5Encrypt64(password);
            var    result      = userRepository.Find(x => x.UserName == userName && x.Password == md5Password);

            if (result.Any())
            {
                var user = result.FirstOrDefault();
                user.OpenId = CookieHelper.GetCookie("OpenId");
                CookieHelper.WriteEncryptCookie(userKey, JsonConvert.SerializeObject(user.ToModel <UserDto>()), DateTime.Now);
                userRepository.Save(user);
            }
            else
            {
                throw new ServiceException("密码错误");
            }
        }
Beispiel #3
0
        public void AdminLogin(string userName, string password)
        {
            if (userName != ConfigHelper.AdminName)
            {
                throw new ServiceException("用户名错误");
            }

            string md5Password = MD5Helper.MD5Encrypt64(password);
            var    result      = userRepository.Find(x => x.UserName == userName && x.Password == md5Password);

            if (result.Any())
            {
                CookieHelper.WriteEncryptCookie(userKey, JsonConvert.SerializeObject(result.FirstOrDefault().ToModel <UserDto>()), DateTime.Now);
            }
            else
            {
                throw new ServiceException("密码错误");
            }
        }