Skip to content
Permalink
Browse files

[#15] Refresh API

  • Loading branch information...
JoMingyu committed Mar 7, 2019
1 parent 27f15be commit 3e0511a9cd64098b3a9d8eea421b229c6ff88be7
Showing with 27 additions and 1 deletion.
  1. +1 −1 app/views/user/account/auth.py
  2. +26 −0 app/views/user/account/refresh.py
@@ -1,6 +1,6 @@
from flask import abort
from flask_jwt_extended import create_access_token, create_refresh_token
from schematics.types import EmailType, StringType
from schematics.types import StringType
from werkzeug.security import check_password_hash

from app.context import context_property
@@ -0,0 +1,26 @@
from flask_jwt_extended import jwt_refresh_token_required, create_access_token, get_jwt_identity

from app.extensions import main_db
from app.models.user import TblUsers
from app.views.base import BaseResource


class RefreshAPI(BaseResource):
@jwt_refresh_token_required
def get(self):
"""
Access token refresh API
"""

session = main_db.session
identity = get_jwt_identity()

user: TblUsers = TblUsers.get_first_or_abort_on_none(
session,
TblUsers.id == identity,
code=401
)

return {
'accessToken': create_access_token(user.id)
}, 201

0 comments on commit 3e0511a

Please sign in to comment.
You can’t perform that action at this time.