Skip to content

Commit

Permalink
Merge pull request #30 from visit1985/logonpage
Browse files Browse the repository at this point in the history
extend logon page to display multiple error messages
  • Loading branch information
LukasReschke committed Oct 15, 2012
2 parents cf7df2d + 7095b3a commit c930ac9
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
15 changes: 13 additions & 2 deletions core/templates/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,20 @@
<form method="post">
<fieldset>
<?php if(!empty($_['redirect'])) { echo '<input type="hidden" name="redirect_url" value="'.$_['redirect'].'" />'; } ?>
<?php if($_['display_lostpassword']): ?>
<a href="./core/lostpassword/"><?php echo $l->t('Lost your password?'); ?></a>
<ul>
<?php if($_['invalidcookie']): ?>
<li class="errors">
<?php echo $l->t('Automatic logon rejected!'); ?><br>
<small><?php echo $l->t('If you did not change your password recently, your account may be compromised!'); ?></small><br>
<small><?php echo $l->t('Please change your password to secure your account again.'); ?></small>
</li>
<?php endif; ?>
<?php if($_['invalidpassword']): ?>
<a href="./core/lostpassword/"><li class="errors">
<?php echo $l->t('Lost your password?'); ?>
</li></a>
<?php endif; ?>
</ul>
<p class="infield">
<label for="user" class="infield"><?php echo $l->t( 'Username' ); ?></label>
<input type="text" name="user" id="user" value="<?php echo $_['username']; ?>"<?php echo $_['user_autofocus']?' autofocus':''; ?> autocomplete="on" required />
Expand Down
10 changes: 5 additions & 5 deletions lib/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -494,20 +494,20 @@ protected static function loadCSSFile() {

protected static function handleLogin() {
OC_App::loadApps(array('prelogin'));
$error = false;
$error = array();
// remember was checked after last login
if (OC::tryRememberLogin()) {
// nothing more to do
$error[] = 'invalidcookie';

// Someone wants to log in :
} elseif (OC::tryFormLogin()) {
$error = true;
$error[] = 'invalidpassword';

// The user is already authenticated using Apaches AuthType Basic... very usable in combination with LDAP
} elseif (OC::tryBasicAuthLogin()) {
$error = true;
$error[] = 'invalidpassword';
}
OC_Util::displayLoginPage($error);
OC_Util::displayLoginPage(array_unique($error));
}

protected static function tryRememberLogin() {
Expand Down
6 changes: 4 additions & 2 deletions lib/util.php
Original file line number Diff line number Diff line change
Expand Up @@ -310,9 +310,11 @@ public static function checkServer() {
return $errors;
}

public static function displayLoginPage($display_lostpassword) {
public static function displayLoginPage($errors = array()) {
$parameters = array();
$parameters['display_lostpassword'] = $display_lostpassword;
foreach( $errors as $key => $value ) {
$parameters[$value] = true;
}
if (!empty($_POST['user'])) {
$parameters["username"] =
OC_Util::sanitizeHTML($_POST['user']).'"';
Expand Down

0 comments on commit c930ac9

Please sign in to comment.