mirror of
https://github.com/moepman/bk-dss
synced 2024-12-22 18:24:27 +01:00
Indention and imports according to PEP8.
This commit is contained in:
parent
f8ef1ec006
commit
8d7b72bf07
14
dss.py
14
dss.py
@ -1,16 +1,15 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import uuid
|
||||||
|
|
||||||
import ldap
|
import ldap
|
||||||
import ldap.modlist
|
import ldap.modlist
|
||||||
import uuid
|
|
||||||
|
|
||||||
from flask import Flask, render_template, redirect, url_for, session
|
from flask import Flask, render_template, redirect, url_for, session
|
||||||
from flask_wtf import FlaskForm
|
from flask_wtf import FlaskForm
|
||||||
from wtforms.fields import IntegerField, PasswordField, SelectField, StringField, SubmitField
|
|
||||||
from wtforms.validators import EqualTo, DataRequired
|
|
||||||
|
|
||||||
from passlib.hash import ldap_salted_sha1
|
from passlib.hash import ldap_salted_sha1
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
|
from wtforms.fields import IntegerField, PasswordField, StringField, SubmitField
|
||||||
|
from wtforms.validators import EqualTo, DataRequired
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.config.from_pyfile('config.cfg')
|
app.config.from_pyfile('config.cfg')
|
||||||
@ -30,6 +29,7 @@ class ReadOnlyField(StringField):
|
|||||||
kwargs.setdefault('readonly', True)
|
kwargs.setdefault('readonly', True)
|
||||||
return super(ReadOnlyField, self).__call__(*args, **kwargs)
|
return super(ReadOnlyField, self).__call__(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class CreateForm(FlaskForm):
|
class CreateForm(FlaskForm):
|
||||||
user = StringField('Username', validators=[DataRequired()])
|
user = StringField('Username', validators=[DataRequired()])
|
||||||
uid = IntegerField('User ID', validators=[DataRequired()])
|
uid = IntegerField('User ID', validators=[DataRequired()])
|
||||||
@ -39,12 +39,14 @@ class CreateForm(FlaskForm):
|
|||||||
pwd2 = PasswordField('Password (repeat)', validators=[DataRequired(), EqualTo('pwd1', "Passwords must match")])
|
pwd2 = PasswordField('Password (repeat)', validators=[DataRequired(), EqualTo('pwd1', "Passwords must match")])
|
||||||
submit = SubmitField('Submit')
|
submit = SubmitField('Submit')
|
||||||
|
|
||||||
|
|
||||||
class EditForm(FlaskForm):
|
class EditForm(FlaskForm):
|
||||||
user = ReadOnlyField('Username')
|
user = ReadOnlyField('Username')
|
||||||
pwd1 = PasswordField('New Password', validators=[DataRequired()])
|
pwd1 = PasswordField('New Password', validators=[DataRequired()])
|
||||||
pwd2 = PasswordField('New Password (repeat)', validators=[DataRequired(), EqualTo('pwd1', "Passwords must match")])
|
pwd2 = PasswordField('New Password (repeat)', validators=[DataRequired(), EqualTo('pwd1', "Passwords must match")])
|
||||||
submit = SubmitField('Submit')
|
submit = SubmitField('Submit')
|
||||||
|
|
||||||
|
|
||||||
class LoginForm(FlaskForm):
|
class LoginForm(FlaskForm):
|
||||||
user = StringField('Username', validators=[DataRequired()])
|
user = StringField('Username', validators=[DataRequired()])
|
||||||
pswd = PasswordField('Password', validators=[DataRequired()])
|
pswd = PasswordField('Password', validators=[DataRequired()])
|
||||||
@ -54,9 +56,11 @@ class LoginForm(FlaskForm):
|
|||||||
def makeSecret(password):
|
def makeSecret(password):
|
||||||
return ldap_salted_sha1.encrypt(password)
|
return ldap_salted_sha1.encrypt(password)
|
||||||
|
|
||||||
|
|
||||||
def isAdmin():
|
def isAdmin():
|
||||||
return isLoggedin() and rdb.hget(session['uuid'], 'user') in app.config.get('ADMINS', [])
|
return isLoggedin() and rdb.hget(session['uuid'], 'user') in app.config.get('ADMINS', [])
|
||||||
|
|
||||||
|
|
||||||
def isLoggedin():
|
def isLoggedin():
|
||||||
return 'uuid' in session and rdb.exists(session['uuid'])
|
return 'uuid' in session and rdb.exists(session['uuid'])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user