diff --git a/app/models.py b/app/models.py index 9ac98da..5eec5ab 100644 --- a/app/models.py +++ b/app/models.py @@ -276,7 +276,7 @@ class User(db.Model): # user already exists in database, set their admin status based on group membership (if enabled) if LDAP_GROUP_SECURITY_ENABLED: self.set_admin(isadmin) - self.update_profile() + return True else: logging.error('Unsupported authentication method') @@ -314,9 +314,9 @@ class User(db.Model): if User.query.count() == 0: self.role_id = Role.query.filter_by(name='Administrator').first().id - self.password = self.get_hashed_password(self.plain_text_password) + self.password = self.get_hashed_password(self.plain_text_password) if self.plain_text_password else '*' - if self.password: + if self.password and self.password != '*': self.password = self.password.decode("utf-8") db.session.add(self) diff --git a/app/templates/admin_setting_authentication.html b/app/templates/admin_setting_authentication.html index ff5924a..e929065 100644 --- a/app/templates/admin_setting_authentication.html +++ b/app/templates/admin_setting_authentication.html @@ -181,10 +181,10 @@
Define how you want to filter your user in LDAP query.
diff --git a/app/templates/login.html b/app/templates/login.html index be201df..54c24bc 100644 --- a/app/templates/login.html +++ b/app/templates/login.html @@ -31,22 +31,14 @@ {{ error }} {% endif %} -
+
- {% if username %} - - {% else %} - - {% endif %} - + +
- {% if password %} - - {% else %} - - {% endif %} - + +
@@ -125,6 +117,10 @@ {% assets "js_login" -%} {%- endassets %} +{% assets "js_validation" -%} + +{%- endassets %} + -{%- endassets %} - - - + + + + + + Register - {{ SITE_NAME }} + + + {% assets "css_login" -%} + + {%- endassets %} + + + + + + +
+ +
+ {% if error %} +
+ + {{ error }} +
+ {% endif %} + + +
+ + + +
+
+ + + +
+
+ + + +
+ +
+ + + +
+
+ + +
+
+ + + +
+
+
+ +
+
+ +
+ +
+ +
+ + +
+ + +{% assets "js_login" -%} + +{%- endassets %} +{% assets "js_validation" -%} + +{%- endassets %} + + + diff --git a/app/views.py b/app/views.py index 9d62c1e..e5e9bd6 100644 --- a/app/views.py +++ b/app/views.py @@ -68,7 +68,7 @@ def before_request(): # check site maintenance mode maintenance = Setting().get('maintenance') - if maintenance and g.user.role.name != 'Administrator': + if maintenance and current_user.is_authenticated and current_user.role.name != 'Administrator': return render_template('maintenance.html') @@ -297,7 +297,6 @@ def login(): email = user_data['email'] user = User.query.filter_by(username=email).first() if not user: - # create user user = User(username=email, firstname=first_name, lastname=surname, @@ -389,15 +388,13 @@ def login(): # registration case user = User(username=username, plain_text_password=password, firstname=firstname, lastname=lastname, email=email) - # TODO: Move this into the JavaScript - # validate password and password confirmation if password != rpassword: error = "Password confirmation does not match" return render_template('register.html', error=error) try: result = user.create_local_user() - if result == True: + if result and result['status']: return render_template('login.html', saml_enabled=SAML_ENABLED, username=username, password=password) else: return render_template('register.html', error=result['msg'])