Skip to content

Commit

Permalink
Merge pull request #21 from bgeo-gis/master
Browse files Browse the repository at this point in the history
Added custom favicon
  • Loading branch information
manisandro authored Jan 4, 2024
2 parents a8d0e1c + 2d34089 commit 8b7ab78
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/db_auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ def __init__(self, tenant, mail, app):
self.login_background = config.get('background_image_url')
self.customstylesheet = config.get('customstylesheet')
self.terms_url = config.get('terms_url')
self.favicon = config.get('favicon')
db_url = config.get('db_url')

# get password constraints from config
Expand Down Expand Up @@ -174,6 +175,7 @@ def login(self):
form.background = self.login_background
form.customstylesheet = self.customstylesheet
form.terms_url = self.terms_url
form.favicon = self.favicon
if form.validate_on_submit():
user = self.find_user(db_session, name=form.username.data)

Expand Down Expand Up @@ -297,6 +299,7 @@ def __verify(self, db_session, submit=True):
form.logo = self.login_logo
form.background = self.login_background
form.customstylesheet = self.customstylesheet
form.favicon = self.favicon
if submit and form.validate_on_submit():
if self.user_totp_is_valid(user, form.token.data, db_session):
# TOTP verified
Expand Down Expand Up @@ -360,6 +363,7 @@ def __setup_totp(self, db_session, submit=True):
form.logo = self.login_logo
form.background = self.login_background
form.customstylesheet = self.customstylesheet
form.favicon = self.favicon
if submit and form.validate_on_submit():
if pyotp.totp.TOTP(totp_secret).verify(
form.token.data, valid_window=1
Expand Down Expand Up @@ -460,6 +464,7 @@ def new_password(self):
form.logo = self.login_logo
form.background = self.login_background
form.customstylesheet = self.customstylesheet
form.favicon = self.favicon
if form.validate_on_submit():
# create session for ConfigDB
db_session = self.db_session()
Expand Down Expand Up @@ -513,6 +518,7 @@ def edit_password(self, token, identity=None):
form.logo = self.login_logo
form.background = self.login_background
form.customstylesheet = self.customstylesheet
form.favicon = self.favicon
if form.validate_on_submit():
# create session for ConfigDB
db_session = self.db_session()
Expand Down Expand Up @@ -637,6 +643,7 @@ def require_password_change(self, user, reason, target_url, db_session):
form.logo = self.login_logo
form.background = self.login_background
form.customstylesheet = self.customstylesheet
form.favicon = self.favicon
# set hidden fields
form.reset_password_token.data = user.reset_password_token
form.url.data = target_url
Expand Down Expand Up @@ -819,7 +826,7 @@ def __login_response(self, user, target_url):
form.logo = self.login_logo
form.background = self.login_background
form.customstylesheet = self.customstylesheet

form.favicon = self.favicon
# show expiry notice
page = render_template(
'notification.html', form=form, i18n=i18n,
Expand Down
3 changes: 3 additions & 0 deletions src/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
{% if form.customstylesheet %}
<link rel="stylesheet" href="{{ url_for('static', filename=form.customstylesheet) }}" type="text/css">
{% endif %}
{% if form.favicon %}
<link rel="icon" href="{{form.favicon}}">
{% endif %}
</head>
<body>
{% if form.background %}
Expand Down

0 comments on commit 8b7ab78

Please sign in to comment.