Esempio n. 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())
Esempio n. 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())
Esempio n. 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)
Esempio n. 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)
Esempio n. 5
0
 def post(self):
     """刷新customer token"""
     return jwt.encode_token('customer', current_customer)
Esempio n. 6
0
 def put(self):
     """刷新app token"""
     return jwt.encode_token('app', current_application)
Esempio n. 7
0
 def put(self):
     """刷新staff token"""
     return jwt.encode_token('staff', current_staff)