暂无描述

profile_routes.py 2.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # IRIS Source Code
  2. # Copyright (C) 2021 - Airbus CyberSecurity (SAS)
  3. # ir@cyberactionlab.net
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 3 of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public License
  16. # along with this program; if not, write to the Free Software Foundation,
  17. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. from flask import Blueprint
  19. from flask import redirect
  20. from flask import render_template
  21. from flask import url_for
  22. from flask_wtf import FlaskForm
  23. from app import app
  24. from app.datamgmt.manage.manage_srv_settings_db import get_server_settings_as_dict
  25. from app.datamgmt.manage.manage_srv_settings_db import get_srv_settings
  26. from app.blueprints.access_controls import ac_requires
  27. profile_blueprint = Blueprint('profile',
  28. __name__,
  29. template_folder='templates')
  30. @profile_blueprint.route('/user/settings', methods=['GET'])
  31. @ac_requires(no_cid_required=True)
  32. def user_settings(caseid, url_redir):
  33. if url_redir:
  34. return redirect(url_for('profile.user_settings', cid=caseid))
  35. if 'SERVER_SETTINGS' not in app.config:
  36. app.config['SERVER_SETTINGS'] = get_server_settings_as_dict()
  37. return render_template('profile.html', mfa_enabled=app.config['SERVER_SETTINGS']['enforce_mfa'])
  38. @profile_blueprint.route('/user/update/modal', methods=['GET'])
  39. @ac_requires(no_cid_required=True)
  40. def update_pwd_modal(caseid, url_redir):
  41. if url_redir:
  42. return redirect(url_for('profile.user_settings', cid=caseid))
  43. form = FlaskForm()
  44. server_settings = get_srv_settings()
  45. return render_template("modal_pwd_user.html", form=form, server_settings=server_settings)