Handle the case where the visitor is already logged-in and tries to login again (#447)

pull/453/head
dgtlmoon 3 years ago committed by GitHub
parent efbeaf9535
commit a709122874
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -127,7 +127,7 @@ def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"):
# return timeago.format(timestamp, time.time()) # return timeago.format(timestamp, time.time())
# return datetime.datetime.utcfromtimestamp(timestamp).strftime(format) # return datetime.datetime.utcfromtimestamp(timestamp).strftime(format)
# When nobody is logged in Flask-Login's current_user is set to an AnonymousUser object.
class User(flask_login.UserMixin): class User(flask_login.UserMixin):
id=None id=None
@ -136,7 +136,6 @@ class User(flask_login.UserMixin):
def get_user(self, email="defaultuser@changedetection.io"): def get_user(self, email="defaultuser@changedetection.io"):
return self return self
def is_authenticated(self): def is_authenticated(self):
return True return True
def is_active(self): def is_active(self):
return True return True
@ -215,6 +214,10 @@ def changedetection_app(config=None, datastore_o=None):
return redirect(url_for('index')) return redirect(url_for('index'))
if request.method == 'GET': if request.method == 'GET':
if flask_login.current_user.is_authenticated:
flash("Already logged in")
return redirect(url_for("index"))
output = render_template("login.html") output = render_template("login.html")
return output return output

Loading…
Cancel
Save