Skip to content

Commit

Permalink
updated login references #25
Browse files Browse the repository at this point in the history
  • Loading branch information
bensteUEM committed Aug 22, 2024
1 parent 4ebb06b commit 4ad5970
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 17 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ version.py is used to define the version number used by any automation
'Docker Compose Up' is using docker-compose.yml and will start a production server including the current version number
'Docker Compose Debug Up' composes a docker container for debugging also including the version number

### nice2know for debugging local docker containers
1. make sure /var/run/docker.sock has group "docker" with rw permissions and user is assigned to group docker
2. docker container IP != local IP - might wanna use the following commands to find the correct IP
- ```docker container list```
- ```docker inspect -f '{{range.NetworkSettings.Networks}}{{.IPAddress}}{{end}} container_name_or_id```
default could be http://172.18.0.2:5000

## tasks.json
does trigger the docker-compose commands used for 2 launch configurations.
This is also where the respective ENV vars can be changed.
Expand Down
26 changes: 17 additions & 9 deletions church_web_helper/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,23 @@ def index():

@app.before_request
def check_session():
if request.endpoint != "login":
if "ct_api" not in session:
return redirect(url_for("login"))
"""Session variable should contain ct_api and communi_api.
If not a redirect to respective login pages should be executed
"""
if request.endpoint != "login_ct" and request.endpoint != "login_communi":
#Check CT Login
if not session.get("ct_api"):
return redirect(url_for("login_ct"))
elif not session["ct_api"].who_am_i():
return redirect(url_for("login"))


@app.route("/login_churchtools", methods=["GET", "POST"])
def login():
return redirect(url_for("login_ct"))
#Check Communi Login
if not session.get("communi_api"):
return redirect(url_for("login_communi"))
elif not session["communi_api"].who_am_i():
return redirect(url_for("login_communi"))

@app.route("/ct/login", methods=["GET", "POST"])
def login_ct():
"""
Update login information for CT
:return:
Expand Down Expand Up @@ -91,7 +99,7 @@ def login():
)


@app.route("/login_communi", methods=["GET", "POST"])
@app.route("/communi/login", methods=["GET", "POST"])
def login_communi():
"""
Update login information for Communi Login
Expand Down
2 changes: 1 addition & 1 deletion church_web_helper/templates/login_churchtools.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ <h2>Welcome {{ user.firstName }} {{ user.lastName }}</h2>
</br></br>
ReSubmit to change the authenticated user or server
{% endif %}
<form action="/login_churchtools" method="POST">
<form action="/ct/login" method="POST">
<div class="form-group">
<label for="ct_domain">Domain:</label>
<input type="text" id="ct_domain" class="form-control" name="ct_domain"
Expand Down
2 changes: 1 addition & 1 deletion church_web_helper/templates/login_communi.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ <h2>Welcome {{ user.vorname }} {{ user.nachname }}</h2>
ReSubmit to change the authenticated user or server
{% endif %}

<form action="/login_communi" method="POST">
<form action="/communi/login" method="POST">
<div class="form-group">
<label for="communi_server">Communi Server:</label>
<input type="text" id="communi_server" class="form-control" name="communi_server"
Expand Down
8 changes: 4 additions & 4 deletions church_web_helper/templates/navbar.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
<a class="nav-link dropdown-toggle" role="button" data-bs-toggle="dropdown" aria-expanded="false">Logins</a>
<ul class="dropdown-menu dropdown-menu-end">
<li class="nav-item">
<a class="nav-link {% if request.path == '/login_churchtools' %}{% endif %}" aria-current="page"
href="/login_churchtools">ChurchTools Login</a>
<a class="nav-link {% if request.path == '/ct/login' %}{% endif %}" aria-current="page"
href="/ct/login">ChurchTools Login</a>
</li>
<li class="nav-item">
<a class="nav-link {% if request.path == '/login_communi' %}{% endif %}" aria-current="page"
href="/login_communi">Communi Login</a>
<a class="nav-link {% if request.path == '/communi/login' %}{% endif %}" aria-current="page"
href="/communi/login">Communi Login</a>
</li>
</ul>
</li>
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "church-web-helper"
version = "1.6.1"
version = "1.6.2"
description = "A python package to make use of ChurchTools API and Communi API with a docker packaged WebUI"
authors = [
"bensteUEM",
Expand Down
2 changes: 1 addition & 1 deletion version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os

VERSION = '1.6.1'
VERSION = '1.6.2'
__version__ = VERSION

if __name__ == '__main__':
Expand Down

0 comments on commit 4ad5970

Please sign in to comment.