示例#1
0
    def get(self):
        """使用app生成staff token"""
        args = uid_args.parse_args()
        uid = args['uid']
        app = current_application

        return jwt.encode_token('staff',
                                app.staffs.filter_by(uid=uid).one_or_none())
示例#2
0
    def get(self):
        """使用app生成customer token"""
        args = uid_args.parse_args()
        uid = args['uid']
        app = current_application

        return jwt.encode_token('customer',
                                app.customers.filter_by(uid=uid).one_or_none())
示例#3
0
def new_staff_token(app_name, uid):
    from app.service.models import App
    from app import jwt

    app = App.query.filter_by(name=app_name).one()
    staff = app.staffs.filter_by(uid=uid).one()

    token = jwt.encode_token('staff', staff)
    logger.info('token: %s', token)
示例#4
0
def auth_token(role, data, get_identity_from_app):
    app_name = data['app_name']
    app_password = data['app_password']

    app = App.authenticate(app_name, app_password)

    if app is None:
        abort(401, 'invalid credentials')

    identity = get_identity_from_app(app, data)
    return jwt.encode_token(role, identity)
示例#5
0
 def post(self):
     """刷新customer token"""
     return jwt.encode_token('customer', current_customer)
示例#6
0
 def put(self):
     """刷新app token"""
     return jwt.encode_token('app', current_application)
示例#7
0
 def put(self):
     """刷新staff token"""
     return jwt.encode_token('staff', current_staff)