templates: add a login template (#40802)
This commit is contained in:
parent
8b939a281e
commit
5e731e5b59
|
@ -0,0 +1,48 @@
|
|||
# welco - multichannel request processing
|
||||
# Copyright (C) 2020 Entr'ouvert
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify it
|
||||
# under the terms of the GNU Affero General Public License as published
|
||||
# by the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Affero General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Affero General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
import pytest
|
||||
|
||||
def login(app, username='toto', password='toto'):
|
||||
login_page = app.get('/login/')
|
||||
login_form = login_page.forms[0]
|
||||
login_form['username'] = username
|
||||
login_form['password'] = password
|
||||
resp = login_form.submit()
|
||||
assert resp.status_int == 302
|
||||
return app
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def logged_app(app, user):
|
||||
return login(app)
|
||||
|
||||
|
||||
def test_unlogged_access(app):
|
||||
# connect while not being logged in
|
||||
assert app.get('/', status=302).location.endswith('/login/?next=/')
|
||||
|
||||
|
||||
def test_access(logged_app, mail_group):
|
||||
resp = logged_app.get('/', status=302)
|
||||
assert resp.location == 'mail/'
|
||||
|
||||
|
||||
def test_logout(logged_app):
|
||||
app = logged_app
|
||||
app.get('/logout/')
|
||||
assert app.get('/', status=302).location.endswith('/login/?next=/')
|
|
@ -0,0 +1,10 @@
|
|||
{% extends "welco/base.html" %}
|
||||
{% load i18n %}
|
||||
|
||||
{% block content %}
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
{{ form }}
|
||||
<button>{% trans 'Log in' %}</button>
|
||||
</form>
|
||||
{% endblock %}
|
|
@ -53,7 +53,7 @@ def login(request, *args, **kwargs):
|
|||
return HttpResponseRedirect(resolve_url('mellon_login'))
|
||||
return HttpResponseRedirect(resolve_url('mellon_login') + '?next='
|
||||
+ quote(request.GET.get('next')))
|
||||
return auth_views.login(request, *args, **kwargs)
|
||||
return auth_views.login(request, template_name='welco/login.html')
|
||||
|
||||
def logout(request, next_page=None):
|
||||
if any(get_idps()):
|
||||
|
|
Loading…
Reference in New Issue