Add remember me checkbox
This commit is contained in:
parent
757beda134
commit
722c601936
3 changed files with 5 additions and 4 deletions
6
auth.py
6
auth.py
|
@ -12,7 +12,7 @@ from flask_login import LoginManager, login_user, logout_user, \
|
|||
login_required, current_user
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_wtf import FlaskForm
|
||||
from wtforms import StringField, PasswordField
|
||||
from wtforms import StringField, PasswordField, BooleanField
|
||||
from wtforms.validators import DataRequired
|
||||
import requests
|
||||
|
||||
|
@ -288,6 +288,7 @@ class LDAPUserProxy(object):
|
|||
class LoginForm(FlaskForm):
|
||||
username = StringField('username', validators=[DataRequired()])
|
||||
password = PasswordField('password', validators=[DataRequired()])
|
||||
remember = BooleanField('remember me')
|
||||
|
||||
|
||||
@app.route('/')
|
||||
|
@ -316,8 +317,7 @@ def login():
|
|||
if not check_credentials(username, password):
|
||||
flash('Invalid username or password')
|
||||
return render_template('login_oauth.html', form=form, next=next)
|
||||
|
||||
login_user(LDAPUserProxy(username))
|
||||
login_user(LDAPUserProxy(username), form.data['remember'])
|
||||
|
||||
flash('Logged in successfully.')
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ body {
|
|||
.form-signin .form-control:focus {
|
||||
z-index: 2;
|
||||
}
|
||||
.form-signin input[type="email"] {
|
||||
.form-signin input[name="username"] {
|
||||
margin-bottom: -1px;
|
||||
border-bottom-right-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
<input name="username" id="inputUsername" class="form-control" placeholder="Username" required autofocus>
|
||||
<label for="inputPassword" class="sr-only">Password</label>
|
||||
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required>
|
||||
<label for="remember">{{ form.remember }} Remember me</label>
|
||||
<button class="btn btn-lg btn-primary btn-block" type="submit">Sign in</button>
|
||||
</form>
|
||||
</div> <!-- /container -->
|
||||
|
|
Loading…
Add table
Reference in a new issue