Skip to content
Open
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
9 changes: 8 additions & 1 deletion core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,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 @@ -287,6 +292,7 @@ public function tryLogin(
ITrustedDomainHelper $trustedDomainHelper,
string $user = '',
string $password = '',
bool $rememberme = false,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool $rememberme = false,
bool $remember_me = false,

for consistency with the other parameters? not sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would force me to rename all the camelCase to rememberMe then for consistency 😒

?string $redirect_url = null,
string $timezone = '',
string $timezone_offset = '',
Expand Down Expand Up @@ -339,9 +345,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
19 changes: 19 additions & 0 deletions core/src/components/login/LoginForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@
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
Expand Down Expand Up @@ -117,6 +128,7 @@ import { loadState } from '@nextcloud/initial-state'
import { translate as t } from '@nextcloud/l10n'
import { generateUrl, imagePath } from '@nextcloud/router'
import debounce from 'debounce'
import NcCheckboxRadioSwitch from '@nextcloud/vue/components/NcCheckboxRadioSwitch'
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
import NcPasswordField from '@nextcloud/vue/components/NcPasswordField'
import NcTextField from '@nextcloud/vue/components/NcTextField'
Expand All @@ -128,6 +140,7 @@ export default {

components: {
LoginButton,
NcCheckboxRadioSwitch,
NcPasswordField,
NcTextField,
NcNoteCard,
Expand Down Expand Up @@ -166,6 +179,11 @@ export default {
default: true,
},

remembermeAllowed: {
type: Boolean,
default: true,
},

directLogin: {
type: Boolean,
default: false,
Expand Down Expand Up @@ -200,6 +218,7 @@ export default {
loading: false,
user: props.username,
password: '',
rememberme: ['1'],
visible: false,
}
},
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 @@ -16,6 +16,7 @@
:errors="errors"
:throttle-delay="throttleDelay"
:auto-complete-allowed="autoCompleteAllowed"
:rememberme-allowed="remembermeAllowed"
:email-states="emailStates"
@submit="loading = true" />
<NcButton
Expand Down Expand Up @@ -148,6 +149,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-common.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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