2013-12-23 02:55:53 +01:00
|
|
|
<?php
|
|
|
|
|
2016-08-25 03:17:58 +02:00
|
|
|
namespace Miniflux\Model\User;
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2014-02-08 20:13:14 +01:00
|
|
|
use PicoDb\Database;
|
2016-08-25 03:17:58 +02:00
|
|
|
use Miniflux\Session;
|
|
|
|
use Miniflux\Request;
|
|
|
|
use Miniflux\Model\Config;
|
|
|
|
use Miniflux\Model\RememberMe;
|
|
|
|
use Miniflux\Model\Database as DatabaseModel;
|
2013-12-23 02:55:53 +01:00
|
|
|
|
2015-01-22 23:12:06 +01:00
|
|
|
// Check if the user is logged in
|
2015-01-17 19:35:59 +01:00
|
|
|
function is_loggedin()
|
2014-11-19 01:00:53 +01:00
|
|
|
{
|
2015-01-22 23:12:06 +01:00
|
|
|
return ! empty($_SESSION['loggedin']);
|
2014-11-19 01:00:53 +01:00
|
|
|
}
|
|
|
|
|
2015-01-18 00:53:40 +01:00
|
|
|
// Destroy the session and the rememberMe cookie
|
2015-01-17 19:35:59 +01:00
|
|
|
function logout()
|
2014-11-19 01:00:53 +01:00
|
|
|
{
|
2015-01-18 00:53:40 +01:00
|
|
|
RememberMe\destroy();
|
|
|
|
Session\close();
|
2014-11-19 01:00:53 +01:00
|
|
|
}
|
|
|
|
|
2015-01-22 23:12:06 +01:00
|
|
|
// Get the credentials from the current selected database
|
2016-03-15 02:34:50 +01:00
|
|
|
function get_credentials()
|
2013-12-23 02:55:53 +01:00
|
|
|
{
|
2015-08-15 03:33:39 +02:00
|
|
|
return Database::getInstance('db')
|
2015-01-28 05:26:36 +01:00
|
|
|
->hashtable('settings')
|
|
|
|
->get('username', 'password');
|
2013-12-23 02:55:53 +01:00
|
|
|
}
|
|
|
|
|
2016-03-15 02:34:50 +01:00
|
|
|
// Set last login date
|
|
|
|
function set_last_login()
|
|
|
|
{
|
|
|
|
return Database::getInstance('db')
|
|
|
|
->hashtable('settings')
|
|
|
|
->put(array('last_login' => time()));
|
|
|
|
}
|