Commit 8077341cf86e71dc02ee830dcd4460d51ed55b07
1 parent
4a6e2799
Exists in
dev
Update logout for django 4.1 (now logout is a button form)
Showing
4 changed files
with
21 additions
and
16 deletions
Show diff stats
CHANGELOG
1 | -30-08-2022 (AKo): V0.5.3 | |
1 | +30-08-2022 (AKo): v0.5.3.1 | |
2 | 2 | - Pyros container has fix hostname (hostname of local machine) |
3 | 3 | - Adding switch of database if we're not in docker and not on the computer that host the database |
4 | 4 | - Add fix IP adress for db_pyros and pyros container, updating database.env files to connect to db_pyros |
5 | + - Add new shell script for build (with verification that user isn't root) | |
6 | + - Fixing endofline issue of windows | |
7 | + - Update logout for Django 4.1 (Send form POST) | |
5 | 8 | |
6 | 9 | 29-08-2022 (AKo): v0.5.2.1 |
7 | 10 | - Adding colors for recieved and sended commands of an agent. | ... | ... |
VERSION
src/core/pyros_django/misc/templates/base.html
... | ... | @@ -387,10 +387,12 @@ footer{ |
387 | 387 | {% endcomment %} |
388 | 388 | |
389 | 389 | <div class="dropdown-divider"></div> |
390 | - <a class="dropdown-item" href="{% url "user_logout" %}" > | |
391 | - <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i> | |
392 | - Logout | |
393 | - </a> | |
390 | + <form> | |
391 | + {% csrf_token %} | |
392 | + <button class="dropdown-item" formaction="{% url "user_logout" %}" formmethod="post" type="submit"> | |
393 | + <i class="fas fa-sign-out-alt fa-sm fa-fw mr-2 text-gray-400"></i> | |
394 | + Logout | |
395 | + </button> | |
394 | 396 | </div> |
395 | 397 | {% else %} |
396 | 398 | <li> <a class="dropwdown-item nav-link" id="signin" href="{% url "user_signin" %}" ><i class="fa fa-power-off"></i> Sign in</a> </li> | ... | ... |
src/core/pyros_django/user_manager/views.py
... | ... | @@ -178,16 +178,16 @@ def user_logout(request): |
178 | 178 | ''' |
179 | 179 | View called to log out. Redirects on login page. |
180 | 180 | ''' |
181 | - | |
182 | - log.info(f"User {request.user} did action logout") | |
183 | - logout(request) | |
184 | - config = OBSConfig( | |
185 | - os.environ["PATH_TO_OBSCONF_FILE"], os.environ["unit_name"]) | |
186 | - observatory_name = config.get_obs_name() | |
187 | - first_unit_name = config.get_units_name()[0] | |
188 | - request.session["obsname"] = observatory_name+" "+first_unit_name | |
189 | - return redirect(reverse("index")) | |
190 | - return(render(request, LOGGED_PAGE, {'USER_LEVEL': "Visitor", 'base_template': 'base.html', 'weather_img': "red"})) | |
181 | + if request.POST: | |
182 | + log.info(f"User {request.user} did action logout") | |
183 | + logout(request) | |
184 | + config = OBSConfig( | |
185 | + os.environ["PATH_TO_OBSCONF_FILE"], os.environ["unit_name"]) | |
186 | + observatory_name = config.get_obs_name() | |
187 | + first_unit_name = config.get_units_name()[0] | |
188 | + request.session["obsname"] = observatory_name+" "+first_unit_name | |
189 | + return redirect(reverse("index")) | |
190 | + return(render(request, LOGGED_PAGE, {'USER_LEVEL': "Visitor", 'base_template': 'base.html', 'weather_img': "red"})) | |
191 | 191 | |
192 | 192 | |
193 | 193 | def user_signin(request): | ... | ... |