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