*/
namespace Friendica\Module;
+use Exception;
use Friendica\BaseModule;
use Friendica\Core\Addon;
use Friendica\Core\Config;
use Friendica\Core\L10n;
-use Friendica\Database\DBM;
+use Friendica\Database\DBA;
use Friendica\Model\User;
use Friendica\Util\DateTimeFormat;
use Friendica\Util\Network;
-use dba;
-use Exception;
use LightOpenID;
require_once 'boot.php';
/**
* Login module
*
- * @author Hypolite Petovan mrpetovan@gmail.com
+ * @author Hypolite Petovan <hypolite@mrpetovan.com>
*/
class Login extends BaseModule
{
goaway(self::getApp()->get_baseurl());
}
- return self::form(self::getApp()->get_baseurl(), Config::get('config', 'register_policy') !== REGISTER_CLOSED);
+ return self::form(self::getApp()->get_baseurl(), intval(Config::get('config', 'register_policy')) !== REGISTER_CLOSED);
}
public static function post()
throw new Exception(L10n::t('Login failed.'));
}
} else {
- $record = dba::selectFirst('user', [],
+ $record = DBA::selectFirst('user', [],
['uid' => User::getIdFromPasswordAuthentication($username, $password)]
);
}
$data = json_decode($_COOKIE["Friendica"]);
if (isset($data->uid)) {
- $user = dba::selectFirst('user', [],
+ $user = DBA::selectFirst('user', [],
[
'uid' => $data->uid,
'blocked' => false,
'verified' => true,
]
);
- if (DBM::is_result($user)) {
+ if (DBA::isResult($user)) {
if ($data->hash != cookie_hash($user)) {
logger("Hash for user " . $data->uid . " doesn't fit.");
nuke_session();
if (isset($_SESSION) && x($_SESSION, 'authenticated')) {
if (x($_SESSION, 'visitor_id') && !x($_SESSION, 'uid')) {
- $r = q("SELECT * FROM `contact` WHERE `id` = %d LIMIT 1",
- intval($_SESSION['visitor_id'])
- );
- if (DBM::is_result($r)) {
- self::getApp()->contact = $r[0];
+ $contact = DBA::selectFirst('contact', [], ['id' => $_SESSION['visitor_id']]);
+ if (DBA::isResult($contact)) {
+ self::getApp()->contact = $contact;
}
}
goaway(self::getApp()->get_baseurl());
}
- $user = dba::selectFirst('user', [],
+ $user = DBA::selectFirst('user', [],
[
'uid' => $_SESSION['uid'],
'blocked' => false,
'verified' => true,
]
);
- if (!DBM::is_result($user)) {
+ if (!DBA::isResult($user)) {
nuke_session();
goaway(self::getApp()->get_baseurl());
}