Internal: Behat, fix login test, fix lost password errors.

pull/3464/head
Julio Montoya 5 years ago
parent bb6d6a5da5
commit bc2785ec7b
  1. 5
      assets/vue/views/Login.vue
  2. 57
      public/main/auth/lostPassword.php
  3. 6
      public/main/inc/lib/login.lib.php
  4. 2
      tests/behat/features/adminFillUsers.feature

@ -10,7 +10,7 @@
@submit="onSubmit"
>
<p class="h4 text-center mb-4">
{{ $t('Sing in') }}
{{ $t('Sign in') }}
</p>
<div class="grey-text">
<b-form-input
@ -30,6 +30,7 @@
required
/>
</div>
<div class="text-center">
<b-button
block
@ -39,6 +40,8 @@
{{ $t('Login') }}
</b-button>
</div>
<a href="/main/auth/lostPassword.php" id="forgot">Forgot password?</a>
</form>
</b-col>
<b-col cols="4" />

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -20,12 +21,12 @@ require_once __DIR__.'/../inc/global.inc.php';
// already be some display output.
// Forbidden to retrieve the lost password
if ('false' == api_get_setting('allow_lostpassword')) {
if ('false' === api_get_setting('allow_lostpassword')) {
api_not_allowed(true);
}
$reset = Request::get('reset');
$userId = Request::get('id');
$reset = $_REQUEST['reset'] ?? '';
$userId = $_REQUEST['id'] ?? '';
$this_section = SECTION_CAMPUS;
@ -34,14 +35,6 @@ $tool_name = get_lang('I lost my password');
if ($reset && $userId) {
$messageText = Login::reset_password($reset, $userId, true);
if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) {
CustomPages::display(
CustomPages::INDEX_UNLOGGED,
['info' => $messageText]
);
exit;
}
Display::addFlash(
Display::return_message($messageText, 'info', false)
);
@ -101,14 +94,6 @@ if ($form->validate()) {
if (!$user) {
$messageText = get_lang('There is no account with this user and/or e-mail address');
if (CustomPages::enabled() && CustomPages::exists(CustomPages::LOST_PASSWORD)) {
CustomPages::display(
CustomPages::LOST_PASSWORD,
['info' => $messageText]
);
exit;
}
Display::addFlash(
Display::return_message($messageText, 'error', false)
);
@ -125,14 +110,6 @@ if ($form->validate()) {
if ('none' === $passwordEncryption) {
$messageText = Login::send_password_to_user($user, true);
if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) {
CustomPages::display(
CustomPages::INDEX_UNLOGGED,
['info' => $messageText]
);
exit;
}
Display::addFlash(
Display::return_message($messageText, 'info', false)
);
@ -140,7 +117,7 @@ if ($form->validate()) {
exit;
}
if ('extldap' == $user['auth_source']) {
if ('extldap' === $user['auth_source']) {
Display::addFlash(
Display::return_message(get_lang('Could not reset password, contact your helpdesk.'), 'info', false)
);
@ -154,28 +131,12 @@ if ($form->validate()) {
$userObj = api_get_user_entity($user['uid']);
Login::sendResetEmail($userObj);
if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) {
CustomPages::display(
CustomPages::INDEX_UNLOGGED,
['info' => get_lang('Check your e-mail and follow the instructions.')]
);
exit;
}
header('Location: '.api_get_path(WEB_PATH));
exit;
}
$messageText = Login::handle_encrypted_password($user, true);
if (CustomPages::enabled() && CustomPages::exists(CustomPages::INDEX_UNLOGGED)) {
CustomPages::display(
CustomPages::INDEX_UNLOGGED,
['info' => $messageText]
);
exit;
}
Display::addFlash(
Display::return_message($messageText, 'info', false)
);
@ -183,14 +144,6 @@ if ($form->validate()) {
exit;
}
if (CustomPages::enabled() && CustomPages::exists(CustomPages::LOST_PASSWORD)) {
CustomPages::display(
CustomPages::LOST_PASSWORD,
['form' => $form->returnForm()]
);
exit;
}
$tpl = new Template(null);
$tpl->assign('content', $form->toHtml());
$tpl->display_one_col_template();

@ -255,7 +255,7 @@ class Login
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$id = intval($id);
$sql = "SELECT
user_id AS uid,
id AS uid,
lastname AS lastName,
firstname AS firstName,
username AS loginName,
@ -263,7 +263,7 @@ class Login
email,
auth_source
FROM ".$tbl_user."
WHERE user_id = $id";
WHERE id = $id";
$result = Database::query($sql);
$num_rows = Database::num_rows($result);
@ -392,7 +392,7 @@ class Login
$tbl_user = Database::get_main_table(TABLE_MAIN_USER);
$query = "SELECT
user_id AS uid,
id AS uid,
lastname AS lastName,
firstname AS firstName,
username AS loginName,

@ -5,7 +5,7 @@ Feature: Fill users
Then I should see "Sign in"
And I fill in "admin" for "login"
And I fill in "admin" for "password"
Then I press "submit"
Then I press "Login"
Then I should not see an error
Scenario: Create tests users successfully

Loading…
Cancel
Save