aboutsummaryrefslogtreecommitdiffstats
path: root/include/auth.php
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2012-08-27 21:17:46 -0700
committerfriendica <info@friendica.com>2012-08-27 21:17:46 -0700
commit7fad83cea4dd134df6dacf8248ef6947dca7f100 (patch)
treec4a8174b8dac64949e874b9149456e2541050f1c /include/auth.php
parent8c3c3d5fd7acc5df0aec9c10f8bdd89bedd2060a (diff)
downloadvolse-hubzilla-7fad83cea4dd134df6dacf8248ef6947dca7f100.tar.gz
volse-hubzilla-7fad83cea4dd134df6dacf8248ef6947dca7f100.tar.bz2
volse-hubzilla-7fad83cea4dd134df6dacf8248ef6947dca7f100.zip
Now logging in with Red zaccount/zentity instead of Friendica user. Yay. Most existing Friendica functionality is now stuffed since the Red structures are quite different.
Diffstat (limited to 'include/auth.php')
-rw-r--r--include/auth.php56
1 files changed, 33 insertions, 23 deletions
diff --git a/include/auth.php b/include/auth.php
index 4dfe74472..1e1df1808 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -5,6 +5,7 @@ require_once('include/security.php');
function nuke_session() {
unset($_SESSION['authenticated']);
+ unset($_SESSION['account_id']);
unset($_SESSION['uid']);
unset($_SESSION['visitor_id']);
unset($_SESSION['administrator']);
@@ -70,7 +71,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
}
}
- if(x($_SESSION,'uid')) {
+ if(x($_SESSION,'uid') || x($_SESSION,'account_id')) {
// already logged in user returning
@@ -83,18 +84,27 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
goaway(z_root());
}
- $r = q("select * from account where account_id = %d limit 1",
- intval($_SESSION['account_id'])
- );
- if(count($r) && (($r[0]['account_flags'] == ACCOUNT_OK) || ($r[0]['account_flags'] == ACCOUNT_UNVERIFIED)))
- get_app()->account = $r[0];
- else
- $_SESSION['account_id'] = 0;
-
- $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 `verified` = 1 LIMIT 1",
- intval($_SESSION['uid'])
- );
+ if(x($_SESSION,'account_id')) {
+ $r = q("select * from account where account_id = %d limit 1",
+ intval($_SESSION['account_id'])
+ );
+ if(count($r) && (($r[0]['account_flags'] == ACCOUNT_OK) || ($r[0]['account_flags'] == ACCOUNT_UNVERIFIED))) {
+ get_app()->account = $r[0];
+ authenticate_success($r[0]);
+ }
+ else {
+ $_SESSION['account_id'] = 0;
+ nuke_session();
+ goaway(z_root());
+ }
+ }
+ else {
+ $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 `verified` = 1 LIMIT 1",
+ intval($_SESSION['uid'])
+ );
+ }
if(! count($r)) {
nuke_session();
@@ -139,7 +149,7 @@ else {
}
else {
- get_app()->account = account_verify_password($_POST['username'],$_POST['password']);
+ $record = get_app()->account = account_verify_password($_POST['username'],$_POST['password']);
if(get_app()->account) {
$_SESSION['account_id'] = get_app()->account['account_id'];
@@ -153,15 +163,15 @@ else {
// process normal login request
- $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
- FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
- AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
- dbesc(trim($_POST['username'])),
- dbesc(trim($_POST['username'])),
- dbesc($encrypted)
- );
- if(count($r))
- $record = $r[0];
+// $r = q("SELECT `user`.*, `user`.`pubkey` as `upubkey`, `user`.`prvkey` as `uprvkey`
+// FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
+// AND `password` = '%s' AND `blocked` = 0 AND `account_expired` = 0 AND `verified` = 1 LIMIT 1",
+// dbesc(trim($_POST['username'])),
+// dbesc(trim($_POST['username'])),
+// dbesc($encrypted)
+// );
+// if(count($r))
+// $record = $r[0];
}
if((! $record) || (! count($record))) {