fix: [login/diagnostic] Return data with the expected format

pull/135/head
mokaddem 2019-10-29 15:12:43 +01:00
parent ce4aa82c0a
commit ad041c5f77
2 changed files with 8 additions and 4 deletions

View File

@ -15,6 +15,8 @@ try:
import json
import flask
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
from halo import Halo
except ModuleNotFoundError as e:
print('Dependency not met. Either not in a virtualenv or dependency not installed.')
@ -441,7 +443,7 @@ def check_server_dynamic_enpoint(spinner):
if '/login' in r_login.url:
o = urlparse(r_login.url)
query = parse_qs(o.query)
error_message = query.get('auth_error_message', 'Unknown error')[0]
error_message = query.get('auth_error_message', ['Unknown error'])[0]
return_text = error_message
return (False, return_text)

View File

@ -143,9 +143,11 @@ class User(UserMixin):
# Logged in, check if logged in user can access the dashboard
me_json = session.get(misp_user_me_page).json()
dashboard_access = me_json.get('UserSetting', {}).get('dashboard_access', False)
if dashboard_access is not False:
return dashboard_access is True or dashboard_access == 1
return None
if dashboard_access is True or dashboard_access == 1:
return (True, '')
else:
return (None, 'User does not have dashboard access')
return (None, '')
@login_manager.user_loader