From 12c957bf5f08fa5eac9b21bb4a1f4adc37de1167 Mon Sep 17 00:00:00 2001 From: thomasDOTde Date: Wed, 1 Nov 2017 01:34:29 +0100 Subject: [PATCH] disabled profile usage when authenticated externally --- app/templates/user_profile.html | 18 +++++++++--------- app/views.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/app/templates/user_profile.html b/app/templates/user_profile.html index 19201dc..2dae7e0 100644 --- a/app/templates/user_profile.html +++ b/app/templates/user_profile.html @@ -19,7 +19,7 @@
-

Edit my profile

+

Edit my profile{% if external_account %} [Disabled - Authenticated externally]{% endif %}

@@ -40,17 +40,17 @@
+ placeholder="{{ current_user.firstname }}" {% if external_account %}disabled{% endif %}>
+ placeholder="{{ current_user.lastname }}" {% if external_account %}disabled{% endif %}>
+ placeholder="{{ current_user.email }}" {% if external_account %}disabled{% endif %}>
@@ -72,7 +72,7 @@
+ id="file" name="file" {% if external_account %}disabled{% endif %}>
@@ -95,15 +95,15 @@
+ id="newpassword" {% if external_account %}disabled{% endif %} />
+ id="rpassword" {% if external_account %}disabled{% endif %} />
-
@@ -112,7 +112,7 @@
- + {% if current_user.otp_secret %}
diff --git a/app/views.py b/app/views.py index 17bbf5d..ff035e4 100644 --- a/app/views.py +++ b/app/views.py @@ -228,6 +228,7 @@ def saml_authorized(): user.lastname = session['samlUserdata']["surname"][0] user.plain_text_password = gen_salt(7) user.update_profile() + session['external_auth'] = True login_user(user, remember=False) return redirect(url_for('index')) else: @@ -259,6 +260,7 @@ def login(): user.create_local_user() session['user_id'] = user.id + session['external_auth'] = True login_user(user, remember = False) return redirect(url_for('index')) @@ -741,8 +743,11 @@ def admin_settings_edit(setting): @app.route('/user/profile', methods=['GET', 'POST']) @login_required def user_profile(): - if request.method == 'GET': - return render_template('user_profile.html') + external_account = False + if session.has_key('external_auth'): + external_account = session['external_auth'] + if request.method == 'GET' or external_account: + return render_template('user_profile.html', external_account=external_account) if request.method == 'POST': # get new profile info firstname = request.form['firstname'] if 'firstname' in request.form else '' @@ -777,7 +782,7 @@ def user_profile(): user = User(username=current_user.username, plain_text_password=new_password, firstname=firstname, lastname=lastname, email=email, avatar=save_file_name, reload_info=False) user.update_profile() - return render_template('user_profile.html') + return render_template('user_profile.html', external_account=external_account) @app.route('/user/avatar/')