Esempio n. 1
0
 def post_login(self, username, password):
     """登录"""
     with db_session:
         u = model.User.get(username=username)
         if _login_auth(u, password):
             me = {"id": u.id}
             header = api.gen_auth_header(me, auth_exp=3600)
             return _out_user(u), header
     abort(403)
Esempio n. 2
0
 def post_login(self, username, password, remember_me):
     """登录"""
     with db_session:
         ok, user = login(username, password)
         if ok:
             me = {
                 "id": user.id,
                 "remember_me": remember_me
             }
             auth_exp = get_auth_exp(remember_me)
             header = api.gen_auth_header(me, auth_exp=auth_exp)
             return user.to_dict(), header
         else:
             abort(403, "用户名或密码错误")
Esempio n. 3
0
 def get_me(self):
     """获取用户的个人信息,调用此接口可以延长token过期时间"""
     me = dict(request.me)
     auth_exp = get_auth_exp(me.get("remember_me"))
     header = api.gen_auth_header(me, auth_exp=auth_exp)
     return self.get(me["id"]), header