Exemple #1
0
 def logout(self):
     user = authentication.get_current_user()
     if user:
         authentication.logout(cherrypy.session)
         UserDao.delete_cookie(user.get('username'))
         self.usetCookie()
     redirect(URL_LOGIN)
Exemple #2
0
def delete(setting_name = None):
    user = authentication.get_current_user()
    if setting_name is None and 'admin' in user.get('role'):
        settingsHandler.factory_reset_all(user.get('burner_sn'))
    else:
        settingsHandler.factory_reset(setting_name, user.get('burner_sn'))
    return get()
Exemple #3
0
def get(setting_name = None):
    user = authentication.get_current_user()
    if setting_name:
        setting_list = [settingsHandler.get_setting(user.get('burner_sn'), setting_name)]
    else:
        setting_list = settingsHandler.get_settings(user.get('burner_sn'), user.get('role'))

    payload = {'settings': setting_list}

    return OkResponse(payload) if len(setting_list) > 0 else ConflictResponse(payload)
def logout():
    # Remove the user information from the session
    app.logger.info("Logout requested")
    user = authentication.get_current_user()
    logout_request = LogoutRequest(name_id=user["misc"]["name_id"],
                                   session_index=user["misc"]["session_index"],
                                   **settings)
    app.logger.info("logout_request.raw_xml=%s", logout_request.raw_xml)
    url = logout_request.get_signed_url(settings["private_key_file"])
    app.logger.info("Logging out: url=%s", url)
    return redirect(url)
Exemple #5
0
 def index(self):
     if authentication.is_logged_in(cherrypy.session):
         user = authentication.get_current_user()
         if authentication.is_master(user):
             redirect(URL_MASTER)
         else:
             customers = assigneesHandler.get_customers(user.get('username'))
             #Normal users can only be assigned to one customer.
             if customers:
                 customer = customers.pop()
                 redirect(URL_USER + str(customer.get('customer')))
             else:
                 redirect(URL_LOGIN)
     else:
         redirect(URL_LOGIN)
Exemple #6
0
    def get(self):
        user = authentication.get_current_user(self.request)
        template_values = {
            'appversion': config.APP_VERSION,
            'allowed_users': authentication.is_member(user, "user-admin"),
            'allowed_groups': authentication.is_member(user, "groups-admin"),
            'allowed_access': authentication.is_member(user, "access-admin"),
            'allowed_admin': authentication.is_member(user, "admin")
        }

        template_values['env'] = [{
            'key': k,
            'value': os.environ[k]
        } for k in sorted(os.environ)]

        template = JINJA_ENVIRONMENT.get_template('index.html')
        self.response.write(template.render(template_values))
def profile():
    """Render profile page."""
    user_data = authentication.get_current_user()
    try:
        organisations = repo.get_organisations_for_person(
            current_user.person_id, auth_token_username=current_user.user_id)

        umbrella_organisations = repo.get_umbrella_organisations_for_person(
            current_user.person_id,
            auth_token_username=current_user.user_id,
        )

        return render_flod_template(
            'profile.html',
            user_data=user_data,
            organisations=organisations,
            umbrella_organisations=umbrella_organisations,
            aktor_url=AKTOR_URL
        )
    except requests.exceptions.ConnectionError:
        app.logger.exception('Request failed')
        return "", 500
def render_flod_template(template, **kwargs):
    stripped_user = None
    pages = page_links
    if not current_user.is_anonymous():
        user = authentication.get_current_user()
        stripped_user = {
            "name": user['name'],
            "uri": "/persons/%d" % user['person_id']
        }

    else:
        pages = {
            'over': [link for link in page_links['over'] if not link.get('requires_login', False)],
            'under': [link for link in page_links['under'] if not link.get('requires_login', False)]
        }

    return render_template(
        template,
        user=stripped_user,
        pages=pages,
        app_name=APP_NAME,
        **kwargs
    )
Exemple #9
0
def put(settingsToUpdate):
    user = authentication.get_current_user()
    res = settingsHandler.update_settings(settingsToUpdate, user.get('burner_sn'))
    return OkResponse(res)