mirror of
https://github.com/moepman/bk-dss
synced 2024-12-22 12:44: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
|
||||
|
||||
import uuid
|
||||
|
||||
import ldap
|
||||
import ldap.modlist
|
||||
import uuid
|
||||
|
||||
from flask import Flask, render_template, redirect, url_for, session
|
||||
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 redis import Redis
|
||||
from wtforms.fields import IntegerField, PasswordField, StringField, SubmitField
|
||||
from wtforms.validators import EqualTo, DataRequired
|
||||
|
||||
app = Flask(__name__)
|
||||
app.config.from_pyfile('config.cfg')
|
||||
@ -30,6 +29,7 @@ class ReadOnlyField(StringField):
|
||||
kwargs.setdefault('readonly', True)
|
||||
return super(ReadOnlyField, self).__call__(*args, **kwargs)
|
||||
|
||||
|
||||
class CreateForm(FlaskForm):
|
||||
user = StringField('Username', 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")])
|
||||
submit = SubmitField('Submit')
|
||||
|
||||
|
||||
class EditForm(FlaskForm):
|
||||
user = ReadOnlyField('Username')
|
||||
pwd1 = PasswordField('New Password', validators=[DataRequired()])
|
||||
pwd2 = PasswordField('New Password (repeat)', validators=[DataRequired(), EqualTo('pwd1', "Passwords must match")])
|
||||
submit = SubmitField('Submit')
|
||||
|
||||
|
||||
class LoginForm(FlaskForm):
|
||||
user = StringField('Username', validators=[DataRequired()])
|
||||
pswd = PasswordField('Password', validators=[DataRequired()])
|
||||
@ -54,9 +56,11 @@ class LoginForm(FlaskForm):
|
||||
def makeSecret(password):
|
||||
return ldap_salted_sha1.encrypt(password)
|
||||
|
||||
|
||||
def isAdmin():
|
||||
return isLoggedin() and rdb.hget(session['uuid'], 'user') in app.config.get('ADMINS', [])
|
||||
|
||||
|
||||
def isLoggedin():
|
||||
return 'uuid' in session and rdb.exists(session['uuid'])
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user