示例#1
0
 def get_authorized_org():
     try:
         return Organization.get_by(
             id=jwt.decode(session['current_org_jwt'],
                           Config.JWT_SECRET_KEY)['payload']['id'])
     except (TypeError, KeyError):
         return None
示例#2
0
 def get(self, org_id, jwt_):
     org = Organization.get_by(id=org_id)
     if org and check_tokens(jwt_, org.api_token):
         session['current_org_jwt'] = create_jwt(
             org.to_dict(only=('id', 'name')))
         return jsonify({'authorization': 'OK'})
     return jsonify({'error': 'incorrect Organization ID or JWT'})