Remove email support from login (fixes #99)
Change-Id: I1915890303c33cfb7a834fd4095e6cfc81e704fe
diff --git a/Changes b/Changes
index 8d08527..77f9e4c 100755
--- a/Changes
+++ b/Changes
@@ -1,4 +1,4 @@
-0.40 2020-11-10
+0.40 2020-11-28
- Modernize ES and fix in-loops.
- add roll() method to state object.
- Fix wrong hint-mirror behaviour in Firefox.
@@ -10,6 +10,8 @@
- Move "use strict" to file level.
- Fix bug where event bubbles when prefix is clicked
in hint menu.
+ - Remove email support from login (as is not
+ or no longer supported by LDAP) (#99).
0.39 2020-10-07
- Add information on secret file to Readme.
diff --git a/dev/demo/all.html b/dev/demo/all.html
index 37d15b6..3aa40ca 100644
--- a/dev/demo/all.html
+++ b/dev/demo/all.html
@@ -71,7 +71,7 @@
<fieldset>
<form>
<legend><span>Anmelden</span></legend>
- <input type="text" name="handle_or_email" placeholder="Benutzername" />
+ <input type="text" name="handle" placeholder="Benutzername" />
<div>
<input type="password" name="pwd" placeholder="Passwort" />
<button type="submit"><span>Go</span></button>
diff --git a/dev/demo/sidebar-login.html b/dev/demo/sidebar-login.html
index 2b127f1..5d395a2 100644
--- a/dev/demo/sidebar-login.html
+++ b/dev/demo/sidebar-login.html
@@ -21,7 +21,7 @@
<fieldset>
<form action="/user/login" method="POST">
<legend><span>Anmelden</span></legend>
- <input name="handle_or_email" placeholder="Benutzername oder Email" type="text">
+ <input name="handle" placeholder="Benutzername" type="text">
<div>
<input name="pwd" placeholder="Passwort" type="password">
<button type="submit"><span>Los!</span></button>
diff --git a/kalamar.dict b/kalamar.dict
index c63ec8f..a18616c 100644
--- a/kalamar.dict
+++ b/kalamar.dict
@@ -35,7 +35,7 @@
by => 'von',
pwd => 'Passwort',
email => 'Email',
- userormail => 'Benutzername oder Email',
+ username => 'Benutzername',
with => 'mit',
glimpse => {
desc => 'Zeige nur die ersten Treffer in beliebiger Reihenfolge'
@@ -122,7 +122,7 @@
by => 'by',
pwd => 'Password',
email => 'Email',
- userormail => 'Username or Email',
+ username => 'Username',
with => 'with',
notAvailInCorpus => 'Not available in the current corpus',
pubOn => 'published on',
diff --git a/lib/Kalamar/Plugin/Auth.pm b/lib/Kalamar/Plugin/Auth.pm
index 8b4fecc..885be07 100644
--- a/lib/Kalamar/Plugin/Auth.pm
+++ b/lib/Kalamar/Plugin/Auth.pm
@@ -499,16 +499,16 @@
# Validate input
my $v = $c->validation;
- $v->required('handle_or_email', 'trim');
+ $v->required('handle', 'trim');
$v->required('pwd', 'trim');
$v->csrf_protect;
$v->optional('fwd')->closed_redirect;
- my $user = $v->param('handle_or_email');
+ my $user = $v->param('handle');
my $fwd = $v->param('fwd');
# Set flash for redirect
- $c->flash(handle_or_email => $user);
+ $c->flash(handle => $user);
if ($v->has_error || index($user, ':') >= 0) {
if ($v->has_error('fwd')) {
@@ -626,7 +626,7 @@
$c->stash(auth => undef);
$c->stash(auth_exp => undef);
- $c->flash(handle_or_email => delete $c->session->{user});
+ $c->flash(handle => delete $c->session->{user});
delete $c->session->{auth};
delete $c->session->{auth_r};
delete $c->session->{auth_exp};
@@ -946,16 +946,16 @@
# Validate input
my $v = $c->validation;
- $v->required('handle_or_email', 'trim');
+ $v->required('handle', 'trim');
$v->required('pwd', 'trim');
$v->csrf_protect;
$v->optional('fwd')->closed_redirect;
- my $user = $v->param('handle_or_email');
+ my $user = $v->param('handle');
my $fwd = $v->param('fwd');
# Set flash for redirect
- $c->flash(handle_or_email => $user);
+ $c->flash(handle => $user);
if ($v->has_error || index($user, ':') >= 0) {
if ($v->has_error('fwd')) {
diff --git a/lib/Kalamar/Plugin/Auth/templates/partial/auth/login.html.ep b/lib/Kalamar/Plugin/Auth/templates/partial/auth/login.html.ep
index d88bd67..61a73a5 100644
--- a/lib/Kalamar/Plugin/Auth/templates/partial/auth/login.html.ep
+++ b/lib/Kalamar/Plugin/Auth/templates/partial/auth/login.html.ep
@@ -1,13 +1,16 @@
%# # user not logged in
% if (!stash('documentation') && !$embedded && !$c->auth->token) {
-% if (flash('handle_or_email') && !param('handle_or_email')) {
-% param(handle_or_email => flash('handle_or_email'));
+% if (flash('handle') && !param('handle')) {
+% param(handle => flash('handle'));
+%# Legacy-Support:
+% } elsif (flash('handle_or_email') && !param('handle_or_email')) {
+% param(handle => flash('handle_or_email'));
% };
<fieldset>
%= form_for 'login', class => 'login', begin
<legend><span><%= loc 'login' %></span></legend>
%= csrf_field
- %= text_field 'handle_or_email', placeholder => loc('userormail')
+ %= text_field 'handle', placeholder => loc('username')
%= hidden_field fwd => $c->url_with
<div>
%= password_field 'pwd', placeholder => loc('pwd')
diff --git a/t/plugin/auth-oauth.t b/t/plugin/auth-oauth.t
index 68fb8bd..117b690 100644
--- a/t/plugin/auth-oauth.t
+++ b/t/plugin/auth-oauth.t
@@ -114,19 +114,19 @@
$t->get_ok('/')
->status_is(200)
- ->element_exists('form[action=/user/login] input[name=handle_or_email]')
+ ->element_exists('form[action=/user/login] input[name=handle]')
->element_exists('aside.active')
->element_exists_not('aside.off')
;
# Test for bug with long password
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'kjskjhndkjndqknaskjnakjdnkjdankajdnkjdsankjdsakjdfkjahzroiuqzriudjoijdmlamdlkmdsalkmdl' })
->status_is(302)
->header_is('Location' => '/');
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'fail' })
->status_is(302)
->header_is('Location' => '/');
@@ -134,11 +134,11 @@
->status_is(200)
->element_exists('div.notify-error')
->text_is('div.notify-error', 'Bad CSRF token')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
;
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'pass' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'pass' })
->status_is(302)
->header_is('Location' => '/');
@@ -151,7 +151,7 @@
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'ldaperr',
csrf_token => $csrf
})
@@ -163,14 +163,14 @@
->status_is(200)
->element_exists('div.notify-error')
->text_is('div.notify-error', '2022: LDAP Authentication failed due to unknown user or password!')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
->element_exists_not('div.notify-success')
->tx->res->dom->at('input[name=csrf_token]')->attr('value')
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'unknown',
csrf_token => $csrf
})
@@ -182,13 +182,13 @@
->status_is(200)
->element_exists('div.notify-error')
->text_is('div.notify-error', '2022: LDAP Authentication failed due to unknown user or password!')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
->tx->res->dom->at('input[name=csrf_token]')->attr('value')
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf
})
@@ -243,8 +243,8 @@
->element_exists_not('div.notify-error')
->element_exists('div.notify-success')
->text_is('div.notify-success', 'Logout successful')
- ->element_exists("input[name=handle_or_email]")
- ->element_exists("input[name=handle_or_email][value=test]")
+ ->element_exists("input[name=handle]")
+ ->element_exists("input[name=handle][value=test]")
;
$t->get_ok('/?q=Baum')
@@ -273,7 +273,7 @@
is($fwd, '/?q=Baum&ql=poliqarp', 'Redirect is valid');
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf,
fwd => 'http://bad.example.com/test'
@@ -289,7 +289,7 @@
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf,
fwd => $fwd
@@ -413,7 +413,7 @@
# Login:
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf
})
diff --git a/t/plugin/auth.t b/t/plugin/auth.t
index e310988..63433b2 100644
--- a/t/plugin/auth.t
+++ b/t/plugin/auth.t
@@ -45,12 +45,12 @@
$t->get_ok('/')
->status_is(200)
- ->element_exists('form[action=/user/login] input[name=handle_or_email]')
+ ->element_exists('form[action=/user/login] input[name=handle]')
->element_exists('aside.active')
->element_exists_not('aside.off')
;
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'fail' })
->status_is(302)
->header_is('Location' => '/');
@@ -58,11 +58,11 @@
->status_is(200)
->element_exists('div.notify-error')
->text_is('div.notify-error', 'Bad CSRF token')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
;
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'pass' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'pass' })
->status_is(302)
->header_is('Location' => '/');
@@ -75,7 +75,7 @@
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'ldaperr',
csrf_token => $csrf
})
@@ -87,13 +87,13 @@
->status_is(200)
->element_exists('div.notify-error')
->text_is('div.notify-error', '2022: LDAP Authentication failed due to unknown user or password!')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
->tx->res->dom->at('input[name=csrf_token]')->attr('value')
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'unknown',
csrf_token => $csrf
})
@@ -105,13 +105,13 @@
->status_is(200)
->element_exists('div.notify-error')
->text_is('div.notify-error', 'Access denied')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
->tx->res->dom->at('input[name=csrf_token]')->attr('value')
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf
})
@@ -169,7 +169,7 @@
is($fwd, '/?q=Baum&ql=poliqarp', 'Redirect is valid');
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf,
fwd => 'http://bad.example.com/test'
@@ -185,7 +185,7 @@
;
$t->post_ok('/user/login' => form => {
- handle_or_email => 'test',
+ handle => 'test',
pwd => 'pass',
csrf_token => $csrf,
fwd => $fwd
diff --git a/t/subfolder.t b/t/subfolder.t
index 01cf33e..e4aa9a4 100644
--- a/t/subfolder.t
+++ b/t/subfolder.t
@@ -12,7 +12,7 @@
$t->app->mode('production');
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'fail' })
->status_is(302)
->header_is('Location' => '/');
@@ -22,7 +22,7 @@
->element_exists('script[src^=/js/kalamar-]')
->element_exists('div.notify-error')
->text_is('div.notify-error', 'Bad CSRF token')
- ->element_exists('input[name=handle_or_email][value=test]')
+ ->element_exists('input[name=handle][value=test]')
->element_exists_not('div.button.top a')
->content_like(qr!KorAP\.URL = ''!)
;
@@ -37,7 +37,7 @@
}
});
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'fail' })
->status_is(302)
->header_is('Location' => '/');
@@ -68,7 +68,7 @@
is('kalamar-koraptest',$t->app->sessions->cookie_name);
ok($t->app->sessions->secure);
-$t->post_ok('/user/login' => form => { handle_or_email => 'test', pwd => 'fail' })
+$t->post_ok('/user/login' => form => { handle => 'test', pwd => 'fail' })
->status_is(302)
->header_is('Location' => '/');