Skip to content
Snippets Groups Projects
Verified Commit d9d88172 authored by nd's avatar nd
Browse files

fix all pylint warnings

parent bdf6ac7a
No related branches found
No related tags found
No related merge requests found
...@@ -144,7 +144,8 @@ disable=missing-module-docstring, ...@@ -144,7 +144,8 @@ disable=missing-module-docstring,
exception-escape, exception-escape,
comprehension-escape, comprehension-escape,
too-few-public-methods, too-few-public-methods,
method-hidden method-hidden,
bad-continuation,
# Enable the message, report, category or checker with the given id(s). You can # Enable the message, report, category or checker with the given id(s). You can
# either give multiple identifier separated by comma (,) or put this option # either give multiple identifier separated by comma (,) or put this option
......
...@@ -48,7 +48,7 @@ def create_app(test_config=None): ...@@ -48,7 +48,7 @@ def create_app(test_config=None):
app.register_blueprint(i) app.register_blueprint(i)
@app.route("/") @app.route("/")
def index(): def index(): #pylint: disable=unused-variable
return redirect(url_for('selfservice.self_index')) return redirect(url_for('selfservice.self_index'))
return app return app
......
from flask import Blueprint, request, session, current_app from flask import Blueprint, current_app
from ldap3.utils.conv import escape_filter_chars from ldap3.utils.conv import escape_filter_chars
from ldap3.utils.dn import escape_rdn from ldap3.utils.dn import escape_rdn
from ldap3.core.exceptions import LDAPBindError from ldap3.core.exceptions import LDAPBindError
...@@ -35,7 +35,6 @@ def uid_to_dn(uid): ...@@ -35,7 +35,6 @@ def uid_to_dn(uid):
conn.search(current_app.config["LDAP_BASE_USER"], '(&(objectclass=person)(uidNumber={}))'.format(escape_filter_chars(uid))) conn.search(current_app.config["LDAP_BASE_USER"], '(&(objectclass=person)(uidNumber={}))'.format(escape_filter_chars(uid)))
if not len(conn.entries) == 1: if not len(conn.entries) == 1:
return None return None
else:
return conn.entries[0].entry_dn return conn.entries[0].entry_dn
def loginname_to_dn(loginname): def loginname_to_dn(loginname):
...@@ -55,5 +54,4 @@ def get_next_uid(): ...@@ -55,5 +54,4 @@ def get_next_uid():
next_uid = max_uid + 1 next_uid = max_uid + 1
if uid_to_dn(next_uid): if uid_to_dn(next_uid):
raise Exception('No free uid found') raise Exception('No free uid found')
else:
return next_uid return next_uid
import datetime import datetime
import secrets import secrets
from sqlalchemy import Column, Integer, String, Text, LargeBinary, DateTime, Boolean, ForeignKey from sqlalchemy import Column, String, DateTime
from uffd.database import db from uffd.database import db
......
...@@ -7,9 +7,9 @@ from flask import Blueprint, render_template, request, url_for, redirect, flash, ...@@ -7,9 +7,9 @@ from flask import Blueprint, render_template, request, url_for, redirect, flash,
from uffd.navbar import register_navbar from uffd.navbar import register_navbar
from uffd.csrf import csrf_protect from uffd.csrf import csrf_protect
from uffd.user.models import User, Group from uffd.user.models import User
from uffd.session import get_current_user, login_required, is_valid_session from uffd.session import get_current_user, login_required, is_valid_session
from uffd.ldap import get_conn, escape_filter_chars, loginname_to_dn from uffd.ldap import loginname_to_dn
from uffd.selfservice.models import PasswordToken, MailToken from uffd.selfservice.models import PasswordToken, MailToken
from uffd.database import db from uffd.database import db
...@@ -72,7 +72,6 @@ def self_token_password(token): ...@@ -72,7 +72,6 @@ def self_token_password(token):
if not 'loginname' in request.values: if not 'loginname' in request.values:
flash('Please set a new password.') flash('Please set a new password.')
return render_template('set_password.html', token=token) return render_template('set_password.html', token=token)
else:
if not request.values['loginname'] == dbtoken.loginname: if not request.values['loginname'] == dbtoken.loginname:
flash('That is not the correct login name for this token. Your token is now invalide. Please start the password reset process again') flash('That is not the correct login name for this token. Your token is now invalide. Please start the password reset process again')
session.delete(dbtoken) session.delete(dbtoken)
...@@ -144,12 +143,12 @@ def send_passwordreset(loginname): ...@@ -144,12 +143,12 @@ def send_passwordreset(loginname):
msg['Subject'] = 'Password reset' msg['Subject'] = 'Password reset'
send_mail(user.mail, msg) send_mail(user.mail, msg)
def send_mail(to, msg): def send_mail(to_address, msg):
server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT']) server = smtplib.SMTP(host=current_app.config['MAIL_SERVER'], port=current_app.config['MAIL_PORT'])
if current_app.config['MAIL_USE_STARTTLS']: if current_app.config['MAIL_USE_STARTTLS']:
server.starttls() server.starttls()
server.login(current_app.config['MAIL_USERNAME'], current_app.config['MAIL_PASSWORD']) server.login(current_app.config['MAIL_USERNAME'], current_app.config['MAIL_PASSWORD'])
msg['From'] = current_app.config['MAIL_FROM_ADDRESS'] msg['From'] = current_app.config['MAIL_FROM_ADDRESS']
msg['To'] = to msg['To'] = to_address
server.send_message(msg) server.send_message(msg)
server.quit() server.quit()
import datetime import datetime
import secrets import secrets
import string
import functools import functools
from flask import Blueprint, render_template, request, url_for, redirect, flash, current_app, session from flask import Blueprint, render_template, request, url_for, redirect, flash, current_app, session
from uffd.navbar import register_navbar
from uffd.csrf import csrf_protect
from uffd.user.models import User from uffd.user.models import User
from uffd.ldap import get_conn, user_conn, uid_to_dn from uffd.ldap import user_conn, uid_to_dn
bp = Blueprint("session", __name__, template_folder='templates', url_prefix='/') bp = Blueprint("session", __name__, template_folder='templates', url_prefix='/')
......
...@@ -10,7 +10,7 @@ from .models import User, Group ...@@ -10,7 +10,7 @@ from .models import User, Group
bp_user = Blueprint("user", __name__, template_folder='templates', url_prefix='/user/') bp_user = Blueprint("user", __name__, template_folder='templates', url_prefix='/user/')
@bp_user.before_request @bp_user.before_request
@login_required() @login_required()
def user_acl(): def user_acl(): #pylint: disable=inconsistent-return-statements
if not user_acl_check(): if not user_acl_check():
flash('Access denied') flash('Access denied')
return redirect(url_for('index')) return redirect(url_for('index'))
...@@ -56,11 +56,11 @@ def user_update(uid=False): ...@@ -56,11 +56,11 @@ def user_update(uid=False):
user = User() user = User()
if not user.set_loginname(request.form['loginname']): if not user.set_loginname(request.form['loginname']):
flash('Login name does not meet requirements') flash('Login name does not meet requirements')
return(url_for('.user_show')) return url_for('.user_show')
user.mail = request.form['mail'] user.mail = request.form['mail']
if not user.set_displayname(request.form['displayname']): if not user.set_displayname(request.form['displayname']):
flash('Display name does not meet requirements') flash('Display name does not meet requirements')
return(url_for('.user_show')) return url_for('.user_show')
new_password = request.form.get('password') new_password = request.form.get('password')
if new_password: if new_password:
user.set_password(new_password) user.set_password(new_password)
...@@ -85,7 +85,7 @@ def user_delete(uid): ...@@ -85,7 +85,7 @@ def user_delete(uid):
bp_group = Blueprint("group", __name__, template_folder='templates', url_prefix='/group/') bp_group = Blueprint("group", __name__, template_folder='templates', url_prefix='/group/')
@bp_group.before_request @bp_group.before_request
@login_required() @login_required()
def group_acl(): def group_acl(): #pylint: disable=inconsistent-return-statements
if not user_acl_check(): if not user_acl_check():
flash('Access denied') flash('Access denied')
return redirect(url_for('index')) return redirect(url_for('index'))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment