]> git.mxchange.org Git - friendica.git/blobdiff - include/auth.php
Merge branch 'pull'
[friendica.git] / include / auth.php
index 768af626fb5863a697e358cda29a793d82cf76e1..45c71c66b3db7944312189b2c7186885f2598f80 100644 (file)
@@ -48,7 +48,8 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p
                        goaway(z_root());
                }
 
-               $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1",
+               $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'])
                );
 
@@ -103,11 +104,12 @@ else {
        if((x($_POST,'password')) && strlen($_POST['password']))
                $encrypted = hash('whirlpool',trim($_POST['password']));
        else {
-               if((x($_POST,'openid_url')) && strlen($_POST['openid_url'])) {
+               if((x($_POST,'openid_url')) && strlen($_POST['openid_url']) ||
+                  (x($_POST,'username')) && strlen($_POST['username'])) {
 
                        $noid = get_config('system','no_openid');
 
-                       $openid_url = trim($_POST['openid_url']);
+                       $openid_url = trim(  (strlen($_POST['openid_url'])?$_POST['openid_url']:$_POST['username']) );
 
                        // validate_url alters the calling parameter
 
@@ -160,7 +162,7 @@ else {
                $record = null;
 
                $addon_auth = array(
-                       'username' => trim($_POST['openid_url']), 
+                       'username' => trim($_POST['username']), 
                        'password' => trim($_POST['password']),
                        'authenticated' => 0,
                        'user_record' => null
@@ -183,10 +185,11 @@ else {
 
                        // process normal login request
 
-                       $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' ) 
-                               AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
-                               dbesc(trim($_POST['openid_url'])),
-                               dbesc(trim($_POST['openid_url'])),
+                       $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))
@@ -194,7 +197,7 @@ else {
                }
 
                if((! $record) || (! count($record))) {
-                       logger('authenticate: failed login attempt: ' . trim($_POST['openid_url'])); 
+                       logger('authenticate: failed login attempt: ' . trim($_POST['username'])); 
                        notice( t('Login failed.') . EOL );
                        goaway(z_root());
                }