mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 23:20:27 +00:00
disabled profile usage when authenticated externally
This commit is contained in:
parent
f3093fe794
commit
12c957bf5f
@ -19,7 +19,7 @@
|
|||||||
<div class="col-lg-12">
|
<div class="col-lg-12">
|
||||||
<div class="box box-primary">
|
<div class="box box-primary">
|
||||||
<div class="box-header with-border">
|
<div class="box-header with-border">
|
||||||
<h3 class="box-title">Edit my profile</h3>
|
<h3 class="box-title">Edit my profile{% if external_account %} [Disabled - Authenticated externally]{% endif %}</h3>
|
||||||
</div>
|
</div>
|
||||||
<div class="box-body">
|
<div class="box-body">
|
||||||
<!-- Custom Tabs -->
|
<!-- Custom Tabs -->
|
||||||
@ -40,17 +40,17 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="firstname">First Name</label> <input type="text"
|
<label for="firstname">First Name</label> <input type="text"
|
||||||
class="form-control" name="firstname" id="firstname"
|
class="form-control" name="firstname" id="firstname"
|
||||||
placeholder="{{ current_user.firstname }}">
|
placeholder="{{ current_user.firstname }}" {% if external_account %}disabled{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="lastname">Last Name</label> <input type="text"
|
<label for="lastname">Last Name</label> <input type="text"
|
||||||
class="form-control" name="lastname" id="lastname"
|
class="form-control" name="lastname" id="lastname"
|
||||||
placeholder="{{ current_user.lastname }}">
|
placeholder="{{ current_user.lastname }}" {% if external_account %}disabled{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="email">E-mail</label> <input type="text"
|
<label for="email">E-mail</label> <input type="text"
|
||||||
class="form-control" name="email" id="email"
|
class="form-control" name="email" id="email"
|
||||||
placeholder="{{ current_user.email }}">
|
placeholder="{{ current_user.email }}" {% if external_account %}disabled{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-flat btn-primary">Submit</button>
|
<button type="submit" class="btn btn-flat btn-primary">Submit</button>
|
||||||
@ -72,7 +72,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<label for="file">Select image</label> <input type="file"
|
<label for="file">Select image</label> <input type="file"
|
||||||
id="file" name="file">
|
id="file" name="file" {% if external_account %}disabled{% endif %}>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
@ -95,15 +95,15 @@
|
|||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="password">New Password</label> <input
|
<label for="password">New Password</label> <input
|
||||||
type="password" class="form-control" name="password"
|
type="password" class="form-control" name="password"
|
||||||
id="newpassword" />
|
id="newpassword" {% if external_account %}disabled{% endif %} />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="rpassword">Re-type New Password</label> <input
|
<label for="rpassword">Re-type New Password</label> <input
|
||||||
type="password" class="form-control" name="rpassword"
|
type="password" class="form-control" name="rpassword"
|
||||||
id="rpassword" />
|
id="rpassword" {% if external_account %}disabled{% endif %} />
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<button type="submit" class="btn btn-flat btn-primary">Change
|
<button type="submit" class="btn btn-flat btn-primary" {% if external_account %}disabled{% endif %}>Change
|
||||||
password</button>
|
password</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
@ -112,7 +112,7 @@
|
|||||||
<div class="tab-pane" id="tabs-authentication">
|
<div class="tab-pane" id="tabs-authentication">
|
||||||
<form action="{{ user_profile }}" method="post">
|
<form action="{{ user_profile }}" method="post">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<input type="checkbox" id="otp_toggle" class="otp_toggle" {% if current_user.otp_secret %}checked{% endif %}>
|
<input type="checkbox" id="otp_toggle" class="otp_toggle" {% if current_user.otp_secret %}checked{% endif %} {% if external_account %}disabled{% endif %}>
|
||||||
<label for="otp_toggle">Enable Two Factor Authentication</label>
|
<label for="otp_toggle">Enable Two Factor Authentication</label>
|
||||||
{% if current_user.otp_secret %}
|
{% if current_user.otp_secret %}
|
||||||
<div id="token_information">
|
<div id="token_information">
|
||||||
|
11
app/views.py
11
app/views.py
@ -228,6 +228,7 @@ def saml_authorized():
|
|||||||
user.lastname = session['samlUserdata']["surname"][0]
|
user.lastname = session['samlUserdata']["surname"][0]
|
||||||
user.plain_text_password = gen_salt(7)
|
user.plain_text_password = gen_salt(7)
|
||||||
user.update_profile()
|
user.update_profile()
|
||||||
|
session['external_auth'] = True
|
||||||
login_user(user, remember=False)
|
login_user(user, remember=False)
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
else:
|
else:
|
||||||
@ -259,6 +260,7 @@ def login():
|
|||||||
user.create_local_user()
|
user.create_local_user()
|
||||||
|
|
||||||
session['user_id'] = user.id
|
session['user_id'] = user.id
|
||||||
|
session['external_auth'] = True
|
||||||
login_user(user, remember = False)
|
login_user(user, remember = False)
|
||||||
return redirect(url_for('index'))
|
return redirect(url_for('index'))
|
||||||
|
|
||||||
@ -741,8 +743,11 @@ def admin_settings_edit(setting):
|
|||||||
@app.route('/user/profile', methods=['GET', 'POST'])
|
@app.route('/user/profile', methods=['GET', 'POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def user_profile():
|
def user_profile():
|
||||||
if request.method == 'GET':
|
external_account = False
|
||||||
return render_template('user_profile.html')
|
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':
|
if request.method == 'POST':
|
||||||
# get new profile info
|
# get new profile info
|
||||||
firstname = request.form['firstname'] if 'firstname' in request.form else ''
|
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 = 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()
|
user.update_profile()
|
||||||
|
|
||||||
return render_template('user_profile.html')
|
return render_template('user_profile.html', external_account=external_account)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/user/avatar/<string:filename>')
|
@app.route('/user/avatar/<string:filename>')
|
||||||
|
Loading…
Reference in New Issue
Block a user