diff --git a/flask_security/changeable.py b/flask_security/changeable.py index 32cf6c1..26f186d 100644 --- a/flask_security/changeable.py +++ b/flask_security/changeable.py @@ -10,7 +10,7 @@ :license: MIT, see LICENSE for more details. """ -from flask import current_app as app, request +from flask import current_app as app from werkzeug.local import LocalProxy from .signals import password_changed diff --git a/flask_security/confirmable.py b/flask_security/confirmable.py index 4edcf8f..ca13d71 100644 --- a/flask_security/confirmable.py +++ b/flask_security/confirmable.py @@ -11,7 +11,7 @@ from datetime import datetime -from flask import current_app as app, request +from flask import current_app as app from werkzeug.local import LocalProxy from .utils import send_mail, md5, url_for_security, get_token_status,\ diff --git a/flask_security/core.py b/flask_security/core.py index 43dd671..692e9bf 100644 --- a/flask_security/core.py +++ b/flask_security/core.py @@ -244,7 +244,7 @@ def _context_processor(): class RoleMixin(object): """Mixin for `Role` model definitions""" def __eq__(self, other): - return (self.name == other or \ + return (self.name == other or self.name == getattr(other, 'name', None)) def __ne__(self, other): @@ -346,10 +346,10 @@ class Security(object): self._state = self.init_app(app, datastore, **kwargs) def init_app(self, app, datastore=None, register_blueprint=True, - login_form=None, confirm_register_form=None, - register_form=None, forgot_password_form=None, - reset_password_form=None, change_password_form=None, - send_confirmation_form=None, passwordless_login_form=None): + login_form=None, confirm_register_form=None, + register_form=None, forgot_password_form=None, + reset_password_form=None, change_password_form=None, + send_confirmation_form=None, passwordless_login_form=None): """Initializes the Flask-Security extension for the specified application and datastore implentation. diff --git a/flask_security/datastore.py b/flask_security/datastore.py index 630389b..bbaecd9 100644 --- a/flask_security/datastore.py +++ b/flask_security/datastore.py @@ -9,6 +9,7 @@ :license: MIT, see LICENSE for more details. """ + class Datastore(object): def __init__(self, db): self.db = db diff --git a/flask_security/forms.py b/flask_security/forms.py index e16c65d..57ab4e7 100644 --- a/flask_security/forms.py +++ b/flask_security/forms.py @@ -96,33 +96,32 @@ class Form(BaseForm): class EmailFormMixin(): - email = TextField(get_form_field_label('email'), - validators=[email_required, - email_validator]) + email = TextField( + get_form_field_label('email'), + validators=[email_required, email_validator]) class UserEmailFormMixin(): user = None - email = TextField(get_form_field_label('email'), - validators=[email_required, - email_validator, - valid_user_email]) + email = TextField( + get_form_field_label('email'), + validators=[email_required, email_validator, valid_user_email]) class UniqueEmailFormMixin(): - email = TextField(get_form_field_label('email'), - validators=[email_required, - email_validator, - unique_user_email]) + email = TextField( + get_form_field_label('email'), + validators=[email_required, email_validator, unique_user_email]) class PasswordFormMixin(): - password = PasswordField(get_form_field_label('password'), - validators=[password_required]) + password = PasswordField( + get_form_field_label('password'), validators=[password_required]) class NewPasswordFormMixin(): - password = PasswordField(get_form_field_label('password'), + password = PasswordField( + get_form_field_label('password'), validators=[password_required, password_length]) @@ -255,10 +254,12 @@ class ResetPasswordForm(Form, NewPasswordFormMixin, PasswordConfirmFormMixin): class ChangePasswordForm(Form, PasswordFormMixin): """The default change password form""" - new_password = PasswordField(get_form_field_label('new_password'), + new_password = PasswordField( + get_form_field_label('new_password'), validators=[password_required, password_length]) - new_password_confirm = PasswordField(get_form_field_label('retype_password'), + new_password_confirm = PasswordField( + get_form_field_label('retype_password'), validators=[EqualTo('new_password', message='RETYPE_PASSWORD_MISMATCH')]) submit = SubmitField(get_form_field_label('change_password')) diff --git a/flask_security/passwordless.py b/flask_security/passwordless.py index 8b6af36..dd6465c 100644 --- a/flask_security/passwordless.py +++ b/flask_security/passwordless.py @@ -9,7 +9,7 @@ :license: MIT, see LICENSE for more details. """ -from flask import request, current_app as app +from flask import current_app as app from werkzeug.local import LocalProxy from .signals import login_instructions_sent diff --git a/flask_security/recoverable.py b/flask_security/recoverable.py index 1f5c027..784faab 100644 --- a/flask_security/recoverable.py +++ b/flask_security/recoverable.py @@ -9,7 +9,7 @@ :license: MIT, see LICENSE for more details. """ -from flask import current_app as app, request +from flask import current_app as app from werkzeug.local import LocalProxy from .signals import password_reset, reset_password_instructions_sent @@ -67,6 +67,7 @@ def reset_password_token_status(token): """ return get_token_status(token, 'reset', 'RESET_PASSWORD') + def update_password(user, password): """Update the specified user's password diff --git a/flask_security/registerable.py b/flask_security/registerable.py index caac983..e4a7e78 100644 --- a/flask_security/registerable.py +++ b/flask_security/registerable.py @@ -38,6 +38,6 @@ def register_user(**kwargs): if config_value('SEND_REGISTER_EMAIL'): send_mail(config_value('EMAIL_SUBJECT_REGISTER'), user.email, 'welcome', - user=user, confirmation_link=confirmation_link) + user=user, confirmation_link=confirmation_link) return user diff --git a/flask_security/utils.py b/flask_security/utils.py index 9258a76..a804a06 100644 --- a/flask_security/utils.py +++ b/flask_security/utils.py @@ -78,8 +78,9 @@ def get_hmac(password): return password if _security.password_salt is None: - raise RuntimeError('The configuration value `SECURITY_PASSWORD_SALT` ' - 'must not be None when the value of `SECURITY_PASSWORD_HASH` is ' + raise RuntimeError( + 'The configuration value `SECURITY_PASSWORD_SALT` must ' + 'not be None when the value of `SECURITY_PASSWORD_HASH` is ' 'set to "%s"' % _security.password_hash) h = hmac.new(_security.password_salt, password.encode('utf-8'), hashlib.sha512) @@ -386,5 +387,3 @@ def capture_signals(): confirm_instructions_sent, login_instructions_sent, password_reset, password_changed, reset_password_instructions_sent]) - -