Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/integration/features/bootstrap/Auth.php
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ public function aNewBrowserSessionIsStarted($remember = false) {
'form_params' => [
'user' => 'user0',
'password' => '123456',
'remember_login' => $remember ? '1' : '0',
'rememberme' => $remember ? '1' : '0',
'requesttoken' => $this->requestToken,
],
'cookies' => $this->cookieJar,
Expand Down
9 changes: 8 additions & 1 deletion core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ public function showLoginForm(?string $user = null, ?string $redirect_url = null
$this->config->getSystemValue('login_form_autocomplete', true) === true
);

$this->initialState->provideInitialState(
'loginCanRememberme',
$this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15) > 0
);

if (!empty($redirect_url)) {
[$url, ] = explode('?', $redirect_url);
if ($url !== $this->urlGenerator->linkToRoute('core.login.logout')) {
Expand Down Expand Up @@ -285,6 +290,7 @@ public function tryLogin(
ITrustedDomainHelper $trustedDomainHelper,
string $user = '',
string $password = '',
bool $rememberme = false,
?string $redirect_url = null,
string $timezone = '',
string $timezone_offset = '',
Expand Down Expand Up @@ -337,9 +343,10 @@ public function tryLogin(
$this->request,
$user,
$password,
$rememberme,
$redirect_url,
$timezone,
$timezone_offset
$timezone_offset,
);
$result = $loginChain->process($data);
if (!$result->isSuccess()) {
Expand Down
17 changes: 17 additions & 0 deletions core/src/components/login/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
data-login-form-input-password
required />

<NcCheckboxRadioSwitch v-if="remembermeAllowed"
id="rememberme"
ref="rememberme"
name="rememberme"
value="1"
:checked.sync="rememberme"
data-login-form-input-rememberme>
{{ t('core', 'Remember me') }}
</NcCheckboxRadioSwitch>

<LoginButton data-login-form-submit :loading="loading" />

<input v-if="redirectUrl"
Expand Down Expand Up @@ -103,6 +113,7 @@ import { translate as t } from '@nextcloud/l10n'
import { generateUrl, imagePath } from '@nextcloud/router'
import debounce from 'debounce'

import NcCheckboxRadioSwitch from '@nextcloud/vue/dist/Components/NcCheckboxRadioSwitch.js'
import NcPasswordField from '@nextcloud/vue/dist/Components/NcPasswordField.js'
import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js'
import NcNoteCard from '@nextcloud/vue/dist/Components/NcNoteCard.js'
Expand All @@ -115,6 +126,7 @@ export default {

components: {
LoginButton,
NcCheckboxRadioSwitch,
NcPasswordField,
NcTextField,
NcNoteCard,
Expand Down Expand Up @@ -147,6 +159,10 @@ export default {
type: Boolean,
default: true,
},
remembermeAllowed: {
type: Boolean,
default: true,
},
directLogin: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -180,6 +196,7 @@ export default {
loading: false,
user: '',
password: '',
rememberme: ['1'],
}
},

Expand Down
2 changes: 2 additions & 0 deletions core/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
:errors="errors"
:throttle-delay="throttleDelay"
:auto-complete-allowed="autoCompleteAllowed"
:rememberme-allowed="remembermeAllowed"
:email-states="emailStates"
@submit="loading = true" />
<a v-if="canResetPassword && resetPasswordLink !== ''"
Expand Down Expand Up @@ -149,6 +150,7 @@ export default {
canResetPassword: loadState('core', 'loginCanResetPassword', false),
resetPasswordLink: loadState('core', 'loginResetPasswordLink', ''),
autoCompleteAllowed: loadState('core', 'loginAutocomplete', true),
remembermeAllowed: loadState('core', 'loginCanRememberme', true),
resetPasswordTarget: loadState('core', 'resetPasswordTarget', ''),
resetPasswordUser: loadState('core', 'resetPasswordUser', ''),
directLogin: query.direct === '1',
Expand Down
4 changes: 2 additions & 2 deletions dist/core-login.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/core-login.js.map

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@ public function __construct(IConfig $config,
}

public function process(LoginData $loginData): LoginResult {
$tokenType = IToken::REMEMBER;
if ($this->config->getSystemValueInt('remember_login_cookie_lifetime', 60 * 60 * 24 * 15) === 0) {
$loginData->setRememberLogin(false);
}
if ($loginData->isRememberLogin()) {
$tokenType = IToken::REMEMBER;
} else {
$tokenType = IToken::DO_NOT_REMEMBER;
}

Expand Down
45 changes: 11 additions & 34 deletions lib/private/Authentication/Login/LoginData.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,25 @@
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/

namespace OC\Authentication\Login;

use OCP\IRequest;
use OCP\IUser;

class LoginData {
/** @var IRequest */
private $request;

/** @var string */
private $username;

/** @var string */
private $password;

/** @var string */
private $redirectUrl;

/** @var string */
private $timeZone;

/** @var string */
private $timeZoneOffset;

/** @var IUser|false|null */
private $user = null;

/** @var bool */
private $rememberLogin = true;

public function __construct(IRequest $request,
string $username,
?string $password,
?string $redirectUrl = null,
string $timeZone = '',
string $timeZoneOffset = '') {
$this->request = $request;
$this->username = $username;
$this->password = $password;
$this->redirectUrl = $redirectUrl;
$this->timeZone = $timeZone;
$this->timeZoneOffset = $timeZoneOffset;
public function __construct(
private IRequest $request,
private string $username,
private ?string $password,
private bool $rememberLogin = true,
private ?string $redirectUrl = null,
private string $timeZone = '',
private string $timeZoneOffset = '',
) {
}

public function getRequest(): IRequest {
Expand Down Expand Up @@ -81,7 +58,7 @@ public function getTimeZoneOffset(): string {
/**
* @param IUser|false|null $user
*/
public function setUser($user) {
public function setUser($user): void {
$this->user = $user;
}

Expand Down
Loading
Loading