From df291db69b68838e1f0c45753e210bc5f059bc08 Mon Sep 17 00:00:00 2001 From: rubenwardy Date: Tue, 29 May 2018 18:27:33 +0100 Subject: [PATCH] Add email/password sign up --- app/models.py | 5 ++++- app/templates/users/claim.html | 16 ++++++++++++++++ app/templates/users/user_profile_page.html | 2 +- app/views/__init__.py | 12 ++++++++---- 4 files changed, 29 insertions(+), 6 deletions(-) diff --git a/app/models.py b/app/models.py index 67a66773..5a4cfac1 100644 --- a/app/models.py +++ b/app/models.py @@ -121,12 +121,15 @@ class User(db.Model, UserMixin): packages = db.relationship("Package", backref="author", lazy="dynamic") requests = db.relationship("EditRequest", backref="author", lazy="dynamic") - def __init__(self, username): + def __init__(self, username, active=False, email=None, password=None): import datetime self.username = username self.confirmed_at = datetime.datetime.now() - datetime.timedelta(days=6000) self.display_name = username + self.active = active + self.email = email + self.password = password self.rank = UserRank.NOT_JOINED def canAccessTodoList(self): diff --git a/app/templates/users/claim.html b/app/templates/users/claim.html index f561a891..ae8e9c99 100644 --- a/app/templates/users/claim.html +++ b/app/templates/users/claim.html @@ -95,5 +95,21 @@ Creating an Account + +
+

Option 3 - Email/password sign up

+ +
+

+ Only do this if you don't have a forum account! +

+

+ If you have a forum account, please use one of the other two + options. +

+ + Register +
+
{% endif %} {% endblock %} diff --git a/app/templates/users/user_profile_page.html b/app/templates/users/user_profile_page.html index 304649ed..755a1582 100644 --- a/app/templates/users/user_profile_page.html +++ b/app/templates/users/user_profile_page.html @@ -32,7 +32,7 @@ Minetest Forum {% elif user == current_user %} - Link Forums Account + No forum account {% endif %} {% if (user.forums_username and user.github_username) or user == current_user %} diff --git a/app/views/__init__.py b/app/views/__init__.py index 21ed40d8..09c7be81 100644 --- a/app/views/__init__.py +++ b/app/views/__init__.py @@ -62,7 +62,11 @@ def flatpage(path): @app.before_request def do_something_whenever_a_request_comes_in(): - if current_user.is_authenticated and current_user.rank == UserRank.BANNED: - flash("You have been banned.", "error") - logout_user() - return redirect(url_for('user.login')) + if current_user.is_authenticated: + if current_user.rank == UserRank.BANNED: + flash("You have been banned.", "error") + logout_user() + return redirect(url_for('user.login')) + elif current_user.rank == UserRank.NOT_JOINED: + current_user.rank = UserRank.MEMBER + db.session.commit()