/**
* Get Auth result
*
* @param \Phire\Table\UserTypes $type
* @return string
*/
public function getAuthResult($type)
{
$result = null;
if (!$this->isValid()) {
$result = $this->getResultMessage();
} else {
$user = $this->getUser();
$session = Table\UserSessions::findBy(array('user_id' => $user['id']));
if (!$type->multiple_sessions && isset($session->id)) {
$result = 'Multiple sessions are not allowed. Someone is already logged on from ' . $session->ip . '.';
} else {
if (!$type->mobile_access && \Pop\Web\Mobile::isMobileDevice()) {
$result = 'Mobile access is not allowed.';
} else {
if (!$user['verified']) {
$result = 'The user is not verified.';
} else {
if ($type->id != $user['type_id']) {
$userType = Table\UserTypes::findById($user['type_id']);
if (isset($userType->id) && !$userType->global_access) {
$result = 'The user is not allowed in this area.';
}
}
}
}
}
}
return $result;
}