示例#1
0
 def test_user(self):
     user = User()
     user.name = "alice"
     user.screen_name = "alice"
     user.email = "*****@*****.**"
     user.set_password("alice_s_password_1234")
     user.create()
     self.assertTrue(User.password_auth("alice", "alice_s_password_1234"))
     jwt = user.get_jwt()
     self.assertEqual(User.check_jwt(jwt), user)
示例#2
0
 def process(self, request, handler):
     sess = request.session()
     try:
         if "jwt_token" in sess:
             request.user = User.check_jwt(sess["jwt_token"])
         else:
             return Response.redirect(
                 request.app.project.login_page
                 + "?redirect_to="
                 + urllib.parse.quote(str(request.url), safe="")
             )
     except Exception:
         return Response.redirect(
             request.app.project.login_page
             + "?redirect_to="
             + urllib.parse.quote(str(request.url), safe="")
         )
     return handler(request)