Beispiel #1
0
 public User ValidateUser(User user)
 {
     if(string.IsNullOrEmpty(user.Password))
     {
         return null;
     }
     if(!string.IsNullOrEmpty(user.UserName))
     {
         return UserDao.ValidateByUserName(user);
     }
     if (!string.IsNullOrEmpty(user.Email))
     {
         return UserDao.ValidateByEmail(user);
     }
     if (!string.IsNullOrEmpty(user.PhoneNumber))
     {
         return UserDao.ValidateByPhoneNumber(user);
     }
     return null;
 }
Beispiel #2
0
 public JsonResult ValidateUser(User user)
 {
     User returnUser = UserService.ValidateUser(user);
     if (returnUser == null)
     {
         //HttpContext.Response.AppendHeader("Access-Control-Allow-Origin", "*");
         return Json(new { }, ResultType.Failure, "用户名或密码错误");
     }
     return Json(
         new
         {
             Id = returnUser.Id,
             UserName = returnUser.UserName,
             Email = returnUser.Email,
             PhoneNumber = returnUser.PhoneNumber
         },
         ResultType.Success,
         ""
         );
 }
Beispiel #3
0
 public User ValidateByEmail(User user)
 {
     return Session.QueryOver<User>().Where(u => (u.Email == user.Email && u.Password == user.Password)).SingleOrDefault();
 }
Beispiel #4
0
 public User ValidateByPhoneNumber(User user)
 {
     return Session.QueryOver<User>().Where(u => (u.PhoneNumber == user.PhoneNumber && u.Password == user.Password)).SingleOrDefault();
 }
Beispiel #5
0
 public User ValidateByUserName(User user)
 {
     return Session.QueryOver<User>().Where(u => (u.UserName == user.UserName && u.Password == user.Password)).SingleOrDefault();
 }