Пример #1
0
 public IHttpActionResult login(loginformation log)
 {
     using (var db = new oucfreetalkEntities())
     {
         var     stu = db.students.FirstOrDefault(a => a.id == log.account);
         results res = new results();
         if (stu == null)
         {
             res.result = 0;//登录失败,没有用户名
             return(Ok(res));
         }
         else
         {
             if (PasswordHash.PasswordHash.ValidatePassword(log.password, stu.password))
             {
                 HttpContext.Current.Session["sid"] = stu.id;
                 res.result = 1;//登录成功
                 return(Ok(res));
             }
             else
             {
                 res.result = 2;//密码错误
                 return(Ok(res));
             }
         }
     }
 }
Пример #2
0
        public IHttpActionResult logout(loginformation log)
        {
            HttpContext.Current.Session.Clear();
            results res = new results();

            res.result = 1;
            return(Ok(res));
        }
Пример #3
0
 public IHttpActionResult login(loginformation log)
 {
     using (var db = new oucfreetalkEntities())
     {
         var stu = db.students.FirstOrDefault(a => a.id == log.account);
         return(Ok(stu));
     }
 }