fixed link to password recovery. removed duplicated and unused code out of index.php.
This commit is contained in:
parent
0514a1925b
commit
c943f48547
2 changed files with 40 additions and 47 deletions
|
@ -1,17 +1,11 @@
|
|||
<form action="index.php" method="post">
|
||||
<fieldset>
|
||||
<?php if($_['error']): ?>
|
||||
<a href="index.php?lostpassword"><?php echo $l->t('Lost your password?'); ?></a>
|
||||
<?php endif; ?>
|
||||
<?php if(empty($_['username'])): ?>
|
||||
<input type="text" name="user" id="user" placeholder="<?php echo $l->t( 'Username' ); ?>" value="<?php echo !empty($_POST['user'])?$_POST['user'].'"':'" autofocus'; ?> autocomplete="off" required />
|
||||
<input type="password" name="password" id="password" placeholder="<?php echo $l->t( 'Password' ); ?>" value="" required <?php echo !empty($_POST['user'])?'autofocus':''; ?> />
|
||||
<input type="checkbox" name="remember_login" value="1" id="remember_login" /><label for="remember_login"><?php echo $l->t('remember'); ?></label>
|
||||
<?php else: ?>
|
||||
<input type="text" name="user" id="user" placeholder="<?php echo $l->t( 'Username' ); ?>" value="<?php echo $_['username']; ?>" autocomplete="off" required >
|
||||
<input type="password" name="password" id="password" placeholder="<?php echo $l->t( 'Password' ); ?>" value="" required autofocus />
|
||||
<input type="checkbox" name="remember_login" value="1" id="remember_login" checked /><label for="remember_login"><?php echo $l->t('remember'); ?></label>
|
||||
<a href="./lostpassword/"><?php echo $l->t('Lost your password?'); ?></a>
|
||||
<?php endif; ?>
|
||||
<input type="text" name="user" id="user" placeholder="<?php echo $l->t( 'Username' ); ?>" value="<?php echo !empty($_POST['user'])?$_POST['user'].'"':'" autofocus'; ?> autocomplete="off" required />
|
||||
<input type="password" name="password" id="password" placeholder="<?php echo $l->t( 'Password' ); ?>" value="" required <?php echo !empty($_POST['user'])?'autofocus':''; ?> />
|
||||
<input type="checkbox" name="remember_login" value="1" id="remember_login" /><label for="remember_login"><?php echo $l->t('remember'); ?></label>
|
||||
<input type="submit" id="submit" class="login" value="<?php echo $l->t( 'Log in' ); ?>" />
|
||||
</fieldset>
|
||||
</form>
|
||||
|
|
73
index.php
73
index.php
|
@ -52,44 +52,43 @@ elseif(OC_User::isLoggedIn()) {
|
|||
}
|
||||
}
|
||||
|
||||
// remember was checked after last login
|
||||
elseif(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) {
|
||||
OC_App::loadApps();
|
||||
if(defined("DEBUG") && DEBUG) {error_log("Trying to login from cookie");}
|
||||
// confirm credentials in cookie
|
||||
if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) &&
|
||||
OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) {
|
||||
OC_User::setUserId($_COOKIE['oc_username']);
|
||||
OC_Util::redirectToDefaultPage();
|
||||
}
|
||||
else {
|
||||
OC_Util::displayLoginPage(array('error' => true));
|
||||
}
|
||||
}
|
||||
|
||||
// Someone wants to log in :
|
||||
elseif(isset($_POST["user"]) && isset($_POST['password'])) {
|
||||
OC_App::loadApps();
|
||||
if(OC_User::login($_POST["user"], $_POST["password"])) {
|
||||
if(!empty($_POST["remember_login"])){
|
||||
if(defined("DEBUG") && DEBUG) {error_log("Setting remember login to cookie");}
|
||||
$token = md5($_POST["user"].time());
|
||||
OC_Preferences::setValue($_POST['user'], 'login', 'token', $token);
|
||||
OC_User::setMagicInCookie($_POST["user"], $token);
|
||||
}
|
||||
else {
|
||||
OC_User::unsetMagicInCookie();
|
||||
}
|
||||
OC_Util::redirectToDefaultPage();
|
||||
} else {
|
||||
OC_Util::displayLoginPage(array('error' => true));
|
||||
}
|
||||
}
|
||||
|
||||
// For all others cases, we display the guest page :
|
||||
else {
|
||||
OC_App::loadApps();
|
||||
OC_Util::displayLoginPage(array('error' => false));
|
||||
}
|
||||
$error = false;
|
||||
|
||||
?>
|
||||
// remember was checked after last login
|
||||
if(isset($_COOKIE["oc_remember_login"]) && isset($_COOKIE["oc_token"]) && isset($_COOKIE["oc_username"]) && $_COOKIE["oc_remember_login"]) {
|
||||
if(defined("DEBUG") && DEBUG) {
|
||||
error_log("Trying to login from cookie");
|
||||
}
|
||||
// confirm credentials in cookie
|
||||
if(isset($_COOKIE['oc_token']) && OC_User::userExists($_COOKIE['oc_username']) &&
|
||||
OC_Preferences::getValue($_COOKIE['oc_username'], "login", "token") == $_COOKIE['oc_token']) {
|
||||
OC_User::setUserId($_COOKIE['oc_username']);
|
||||
OC_Util::redirectToDefaultPage();
|
||||
}
|
||||
}
|
||||
|
||||
// Someone wants to log in :
|
||||
elseif(isset($_POST["user"]) && isset($_POST['password'])) {
|
||||
if(OC_User::login($_POST["user"], $_POST["password"])) {
|
||||
if(!empty($_POST["remember_login"])){
|
||||
if(defined("DEBUG") && DEBUG) {
|
||||
error_log("Setting remember login to cookie");
|
||||
}
|
||||
$token = md5($_POST["user"].time());
|
||||
OC_Preferences::setValue($_POST['user'], 'login', 'token', $token);
|
||||
OC_User::setMagicInCookie($_POST["user"], $token);
|
||||
}
|
||||
else {
|
||||
OC_User::unsetMagicInCookie();
|
||||
}
|
||||
OC_Util::redirectToDefaultPage();
|
||||
} else {
|
||||
$error = true;
|
||||
}
|
||||
}
|
||||
|
||||
OC_Template::printGuestPage('', 'login', array('error' => $error ));
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue