Skip to content

Commit

Permalink
Merge pull request #7590 from nextcloud/flow-hide-stay-logged-in
Browse files Browse the repository at this point in the history
Hide stay logged in checkbox when flow authentication is used
  • Loading branch information
MorrisJobke authored Jan 2, 2018
2 parents 9e49b6e + f5f6ed6 commit 37ed5b5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/Controller/LoginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ public function showLoginForm($user, $redirect_url, $remember_login) {

$parameters['alt_login'] = OC_App::getAlternativeLogIns();
$parameters['rememberLoginState'] = !empty($remember_login) ? $remember_login : 0;
$parameters['hideRemeberLoginState'] = !empty($redirect_url) && $this->session->exists('client.flow.state.token');

if (!is_null($user) && $user !== '') {
$parameters['loginName'] = $user;
Expand Down
2 changes: 2 additions & 0 deletions core/templates/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
<?php } ?>

<div class="login-additional">
<?php if (!$_['hideRemeberLoginState']) { ?>
<div class="remember-login-container">
<?php if ($_['rememberLoginState'] === 0) { ?>
<input type="checkbox" name="remember_login" value="1" id="remember_login" class="checkbox checkbox--white">
Expand All @@ -78,6 +79,7 @@
<?php } ?>
<label for="remember_login"><?php p($l->t('Stay logged in')); ?></label>
</div>
<?php } ?>
<?php if (!empty($_['canResetPassword'])) { ?>
<div class="lost-password-container">
<a id="lost-password" href="<?php p($_['resetPasswordLink']); ?>">
Expand Down
33 changes: 33 additions & 0 deletions tests/Core/Controller/LoginControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,12 +182,43 @@ public function testShowLoginFormWithErrorsInSession() {
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => null,
'hideRemeberLoginState' => false,
],
'guest'
);
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', '', ''));
}

public function testShowLoginFormForFlowAuth() {
$this->userSession
->expects($this->once())
->method('isLoggedIn')
->willReturn(false);
$this->session
->expects($this->once())
->method('exists')
->with('client.flow.state.token')
->willReturn(true);

$expectedResponse = new TemplateResponse(
'core',
'login',
[
'messages' => [],
'redirect_url' => 'login/flow',
'loginName' => '',
'user_autofocus' => true,
'canResetPassword' => true,
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => null,
'hideRemeberLoginState' => true,
],
'guest'
);
$this->assertEquals($expectedResponse, $this->loginController->showLoginForm('', 'login/flow', ''));
}

/**
* @return array
*/
Expand Down Expand Up @@ -240,6 +271,7 @@ public function testShowLoginFormWithPasswordResetOption($canChangePassword,
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => false,
'hideRemeberLoginState' => false,
],
'guest'
);
Expand Down Expand Up @@ -278,6 +310,7 @@ public function testShowLoginFormForUserNamedNull() {
'alt_login' => [],
'rememberLoginState' => 0,
'resetPasswordLink' => false,
'hideRemeberLoginState' => false,
],
'guest'
);
Expand Down

0 comments on commit 37ed5b5

Please sign in to comment.