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
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'})