"Remember Me" should work now but needs more fine tuning
This commit is contained in:
parent
da7040efd4
commit
af8b3b1fb7
|
@ -1,6 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
|
||||||
require_once('include/security.php');
|
require_once('include/security.php');
|
||||||
require_once('include/datetime.php');
|
require_once('include/datetime.php');
|
||||||
|
|
||||||
|
@ -13,7 +11,6 @@ function nuke_session() {
|
||||||
// When the "Friendica" cookie is set, take the value to authenticate and renew the cookie.
|
// When the "Friendica" cookie is set, take the value to authenticate and renew the cookie.
|
||||||
if(isset($_COOKIE["Friendica"])) {
|
if(isset($_COOKIE["Friendica"])) {
|
||||||
$data = json_decode($_COOKIE["Friendica"]);
|
$data = json_decode($_COOKIE["Friendica"]);
|
||||||
|
|
||||||
if (isset($data->uid)) {
|
if (isset($data->uid)) {
|
||||||
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
|
$r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
|
||||||
FROM `user` WHERE `uid` = %d AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
|
FROM `user` WHERE `uid` = %d AND `blocked` = 0 AND `account_expired` = 0 AND `account_removed` = 0 AND `verified` = 1 LIMIT 1",
|
||||||
|
@ -26,7 +23,7 @@ if(isset($_COOKIE["Friendica"])) {
|
||||||
|
|
||||||
// Do the authentification if not done by now
|
// Do the authentification if not done by now
|
||||||
if(!isset($_SESSION) OR !isset($_SESSION['authenticated'])) {
|
if(!isset($_SESSION) OR !isset($_SESSION['authenticated'])) {
|
||||||
authenticate_success($r[0], false, false, false);
|
authenticate_success($r[0]);
|
||||||
|
|
||||||
if (get_config('system','paranoia'))
|
if (get_config('system','paranoia'))
|
||||||
$_SESSION['addr'] = $data->ip;
|
$_SESSION['addr'] = $data->ip;
|
||||||
|
@ -35,6 +32,7 @@ if(isset($_COOKIE["Friendica"])) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// login/logout
|
// login/logout
|
||||||
|
|
||||||
if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-params'))) || ($_POST['auth-params'] !== 'login'))) {
|
if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-params'))) || ($_POST['auth-params'] !== 'login'))) {
|
||||||
|
@ -44,7 +42,6 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
|
||||||
// process logout request
|
// process logout request
|
||||||
call_hooks("logging_out");
|
call_hooks("logging_out");
|
||||||
nuke_session();
|
nuke_session();
|
||||||
new_cookie(-1);
|
|
||||||
info(t('Logged out.').EOL);
|
info(t('Logged out.').EOL);
|
||||||
goaway(z_root());
|
goaway(z_root());
|
||||||
}
|
}
|
||||||
|
@ -96,9 +93,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if(isset($_SESSION)) {
|
session_unset();
|
||||||
nuke_session();
|
|
||||||
}
|
|
||||||
|
|
||||||
if((x($_POST,'password')) && strlen($_POST['password']))
|
if((x($_POST,'password')) && strlen($_POST['password']))
|
||||||
$encrypted = hash('whirlpool',trim($_POST['password']));
|
$encrypted = hash('whirlpool',trim($_POST['password']));
|
||||||
|
@ -163,8 +158,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
|
||||||
|
|
||||||
if(($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
|
if(($addon_auth['authenticated']) && (count($addon_auth['user_record']))) {
|
||||||
$record = $addon_auth['user_record'];
|
$record = $addon_auth['user_record'];
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
// process normal login request
|
// process normal login request
|
||||||
|
|
||||||
|
@ -206,7 +200,8 @@ function new_cookie($time, $value = "") {
|
||||||
if ($time != 0)
|
if ($time != 0)
|
||||||
$time = $time + time();
|
$time = $time + time();
|
||||||
|
|
||||||
setcookie("Friendica", $value, $time);
|
setcookie("Friendica", $value, $time, "/", "",
|
||||||
|
(get_config('system', 'ssl_policy') == SSL_POLICY_FULL), true);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ if((x($_GET,'zrl')) && (!$install && !$maintenance)) {
|
||||||
|
|
||||||
// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
|
// header('Link: <' . $a->get_baseurl() . '/amcd>; rel="acct-mgmt";');
|
||||||
|
|
||||||
if((x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
|
if(x($_COOKIE["Friendica"]) || (x($_SESSION,'authenticated')) || (x($_POST,'auth-params')) || ($a->module === 'login'))
|
||||||
require("include/auth.php");
|
require("include/auth.php");
|
||||||
|
|
||||||
if(! x($_SESSION,'authenticated'))
|
if(! x($_SESSION,'authenticated'))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user