/**
* Get currently logged in user's uid.
*
* @return uint|false Return uid of the loggedin user, or return
* false if user isn't loggedin.
*/
public function getLoggedInUser()
{
// Get user from cached data or from access token
$user = $this->getUser();
// If there's bd_sig & bd_user parameter in query parameters,
// it must be an inside web app(app on baidu) loading request,
// then we must check whether the uid passed from baidu is the
// same as we get from persistent data or from access token,
// if it's not, we should clear all the persistent data and to
// get an access token again.
if (isset($_REQUEST['bd_sig']) && isset($_REQUEST['bd_user'])) {
$params = array('bd_user' => $_REQUEST['bd_user']);
$sig = BaiduUtils::generateSign($params, $this->clientSecret, 'bd_sig');
if ($sig != $_REQUEST['bd_sig'] || $user['uid'] != $_REQUEST['bd_user']) {
$this->store->remove('session');
return false;
}
}
return $user;
}