You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

662 lines
21 KiB

11 years ago
12 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
11 years ago
  1. <?php
  2. /**
  3. * Copyright (c) 2013 Robin Appelman <icewind@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\User;
  9. use OC\Session\Memory;
  10. use OC\User\User;
  11. /**
  12. * @group DB
  13. * @package Test\User
  14. */
  15. class SessionTest extends \Test\TestCase {
  16. /** @var \OCP\AppFramework\Utility\ITimeFactory */
  17. private $timeFactory;
  18. /** @var \OC\Authentication\Token\DefaultTokenProvider */
  19. protected $defaultProvider;
  20. /** @var \OCP\IConfig */
  21. private $config;
  22. protected function setUp() {
  23. parent::setUp();
  24. $this->timeFactory = $this->getMock('\OCP\AppFramework\Utility\ITimeFactory');
  25. $this->timeFactory->expects($this->any())
  26. ->method('getTime')
  27. ->will($this->returnValue(10000));
  28. $this->defaultProvider = $this->getMockBuilder('\OC\Authentication\Token\DefaultTokenProvider')
  29. ->disableOriginalConstructor()
  30. ->getMock();
  31. $this->config = $this->getMock('\OCP\IConfig');
  32. }
  33. public function testGetUser() {
  34. $token = new \OC\Authentication\Token\DefaultToken();
  35. $token->setLoginName('User123');
  36. $expectedUser = $this->getMock('\OCP\IUser');
  37. $expectedUser->expects($this->any())
  38. ->method('getUID')
  39. ->will($this->returnValue('user123'));
  40. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  41. $session->expects($this->at(0))
  42. ->method('get')
  43. ->with('user_id')
  44. ->will($this->returnValue($expectedUser->getUID()));
  45. $sessionId = 'abcdef12345';
  46. $manager = $this->getMockBuilder('\OC\User\Manager')
  47. ->disableOriginalConstructor()
  48. ->getMock();
  49. $session->expects($this->once())
  50. ->method('getId')
  51. ->will($this->returnValue($sessionId));
  52. $this->defaultProvider->expects($this->once())
  53. ->method('getToken')
  54. ->will($this->returnValue($token));
  55. $session->expects($this->at(2))
  56. ->method('get')
  57. ->with('last_login_check')
  58. ->will($this->returnValue(null)); // No check has been run yet
  59. $this->defaultProvider->expects($this->once())
  60. ->method('getPassword')
  61. ->with($token, $sessionId)
  62. ->will($this->returnValue('password123'));
  63. $manager->expects($this->once())
  64. ->method('checkPassword')
  65. ->with('User123', 'password123')
  66. ->will($this->returnValue(true));
  67. $expectedUser->expects($this->once())
  68. ->method('isEnabled')
  69. ->will($this->returnValue(true));
  70. $session->expects($this->at(3))
  71. ->method('set')
  72. ->with('last_login_check', 10000);
  73. $session->expects($this->at(4))
  74. ->method('get')
  75. ->with('last_token_update')
  76. ->will($this->returnValue(null)); // No check run so far
  77. $this->defaultProvider->expects($this->once())
  78. ->method('updateToken')
  79. ->with($token);
  80. $session->expects($this->at(5))
  81. ->method('set')
  82. ->with('last_token_update', $this->equalTo(10000));
  83. $manager->expects($this->any())
  84. ->method('get')
  85. ->with($expectedUser->getUID())
  86. ->will($this->returnValue($expectedUser));
  87. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  88. $user = $userSession->getUser();
  89. $this->assertSame($expectedUser, $user);
  90. }
  91. public function isLoggedInData() {
  92. return [
  93. [true],
  94. [false],
  95. ];
  96. }
  97. /**
  98. * @dataProvider isLoggedInData
  99. */
  100. public function testIsLoggedIn($isLoggedIn) {
  101. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  102. $manager = $this->getMockBuilder('\OC\User\Manager')
  103. ->disableOriginalConstructor()
  104. ->getMock();
  105. $userSession = $this->getMockBuilder('\OC\User\Session')
  106. ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->defaultProvider, $this->config])
  107. ->setMethods([
  108. 'getUser'
  109. ])
  110. ->getMock();
  111. $user = new User('sepp', null);
  112. $userSession->expects($this->once())
  113. ->method('getUser')
  114. ->will($this->returnValue($isLoggedIn ? $user : null));
  115. $this->assertEquals($isLoggedIn, $userSession->isLoggedIn());
  116. }
  117. public function testSetUser() {
  118. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  119. $session->expects($this->once())
  120. ->method('set')
  121. ->with('user_id', 'foo');
  122. $manager = $this->getMock('\OC\User\Manager');
  123. $backend = $this->getMock('\Test\Util\User\Dummy');
  124. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  125. $user->expects($this->once())
  126. ->method('getUID')
  127. ->will($this->returnValue('foo'));
  128. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  129. $userSession->setUser($user);
  130. }
  131. public function testLoginValidPasswordEnabled() {
  132. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  133. $session->expects($this->once())
  134. ->method('regenerateId');
  135. $session->expects($this->exactly(2))
  136. ->method('set')
  137. ->with($this->callback(function ($key) {
  138. switch ($key) {
  139. case 'user_id':
  140. case 'loginname':
  141. return true;
  142. break;
  143. default:
  144. return false;
  145. break;
  146. }
  147. }, 'foo'));
  148. $managerMethods = get_class_methods('\OC\User\Manager');
  149. //keep following methods intact in order to ensure hooks are
  150. //working
  151. $doNotMock = array('__construct', 'emit', 'listen');
  152. foreach ($doNotMock as $methodName) {
  153. $i = array_search($methodName, $managerMethods, true);
  154. if ($i !== false) {
  155. unset($managerMethods[$i]);
  156. }
  157. }
  158. $manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
  159. $backend = $this->getMock('\Test\Util\User\Dummy');
  160. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  161. $user->expects($this->any())
  162. ->method('isEnabled')
  163. ->will($this->returnValue(true));
  164. $user->expects($this->any())
  165. ->method('getUID')
  166. ->will($this->returnValue('foo'));
  167. $user->expects($this->once())
  168. ->method('updateLastLoginTimestamp');
  169. $manager->expects($this->once())
  170. ->method('checkPassword')
  171. ->with('foo', 'bar')
  172. ->will($this->returnValue($user));
  173. $userSession = $this->getMockBuilder('\OC\User\Session')
  174. ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->defaultProvider, $this->config])
  175. ->setMethods([
  176. 'prepareUserLogin'
  177. ])
  178. ->getMock();
  179. $userSession->expects($this->once())
  180. ->method('prepareUserLogin');
  181. $userSession->login('foo', 'bar');
  182. $this->assertEquals($user, $userSession->getUser());
  183. }
  184. /**
  185. * @expectedException \OC\User\LoginException
  186. */
  187. public function testLoginValidPasswordDisabled() {
  188. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  189. $session->expects($this->never())
  190. ->method('set');
  191. $session->expects($this->once())
  192. ->method('regenerateId');
  193. $managerMethods = get_class_methods('\OC\User\Manager');
  194. //keep following methods intact in order to ensure hooks are
  195. //working
  196. $doNotMock = array('__construct', 'emit', 'listen');
  197. foreach ($doNotMock as $methodName) {
  198. $i = array_search($methodName, $managerMethods, true);
  199. if ($i !== false) {
  200. unset($managerMethods[$i]);
  201. }
  202. }
  203. $manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
  204. $backend = $this->getMock('\Test\Util\User\Dummy');
  205. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  206. $user->expects($this->any())
  207. ->method('isEnabled')
  208. ->will($this->returnValue(false));
  209. $user->expects($this->never())
  210. ->method('updateLastLoginTimestamp');
  211. $manager->expects($this->once())
  212. ->method('checkPassword')
  213. ->with('foo', 'bar')
  214. ->will($this->returnValue($user));
  215. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  216. $userSession->login('foo', 'bar');
  217. }
  218. public function testLoginInvalidPassword() {
  219. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  220. $session->expects($this->never())
  221. ->method('set');
  222. $session->expects($this->once())
  223. ->method('regenerateId');
  224. $managerMethods = get_class_methods('\OC\User\Manager');
  225. //keep following methods intact in order to ensure hooks are
  226. //working
  227. $doNotMock = array('__construct', 'emit', 'listen');
  228. foreach ($doNotMock as $methodName) {
  229. $i = array_search($methodName, $managerMethods, true);
  230. if ($i !== false) {
  231. unset($managerMethods[$i]);
  232. }
  233. }
  234. $manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
  235. $backend = $this->getMock('\Test\Util\User\Dummy');
  236. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  237. $user->expects($this->never())
  238. ->method('isEnabled');
  239. $user->expects($this->never())
  240. ->method('updateLastLoginTimestamp');
  241. $manager->expects($this->once())
  242. ->method('checkPassword')
  243. ->with('foo', 'bar')
  244. ->will($this->returnValue(false));
  245. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  246. $userSession->login('foo', 'bar');
  247. }
  248. public function testLoginNonExisting() {
  249. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  250. $session->expects($this->never())
  251. ->method('set');
  252. $session->expects($this->once())
  253. ->method('regenerateId');
  254. $manager = $this->getMock('\OC\User\Manager');
  255. $backend = $this->getMock('\Test\Util\User\Dummy');
  256. $manager->expects($this->once())
  257. ->method('checkPassword')
  258. ->with('foo', 'bar')
  259. ->will($this->returnValue(false));
  260. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  261. $userSession->login('foo', 'bar');
  262. }
  263. public function testLogClientInNoTokenPasswordWith2fa() {
  264. $manager = $this->getMockBuilder('\OC\User\Manager')
  265. ->disableOriginalConstructor()
  266. ->getMock();
  267. $session = $this->getMock('\OCP\ISession');
  268. /** @var \OC\User\Session $userSession */
  269. $userSession = $this->getMockBuilder('\OC\User\Session')
  270. ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->defaultProvider, $this->config])
  271. ->setMethods(['login'])
  272. ->getMock();
  273. $this->defaultProvider->expects($this->once())
  274. ->method('getToken')
  275. ->with('doe')
  276. ->will($this->throwException(new \OC\Authentication\Exceptions\InvalidTokenException()));
  277. $this->config->expects($this->once())
  278. ->method('getSystemValue')
  279. ->with('token_auth_enforced', false)
  280. ->will($this->returnValue(true));
  281. $this->assertFalse($userSession->logClientIn('john', 'doe'));
  282. }
  283. public function testLogClientInNoTokenPasswordNo2fa() {
  284. $manager = $this->getMockBuilder('\OC\User\Manager')
  285. ->disableOriginalConstructor()
  286. ->getMock();
  287. $session = $this->getMock('\OCP\ISession');
  288. $user = $this->getMock('\OCP\IUser');
  289. /** @var \OC\User\Session $userSession */
  290. $userSession = $this->getMockBuilder('\OC\User\Session')
  291. ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->defaultProvider, $this->config])
  292. ->setMethods(['login', 'isTwoFactorEnforced'])
  293. ->getMock();
  294. $this->defaultProvider->expects($this->once())
  295. ->method('getToken')
  296. ->with('doe')
  297. ->will($this->throwException(new \OC\Authentication\Exceptions\InvalidTokenException()));
  298. $this->config->expects($this->once())
  299. ->method('getSystemValue')
  300. ->with('token_auth_enforced', false)
  301. ->will($this->returnValue(false));
  302. $userSession->expects($this->once())
  303. ->method('isTwoFactorEnforced')
  304. ->with('john')
  305. ->will($this->returnValue(true));
  306. $this->assertFalse($userSession->logClientIn('john', 'doe'));
  307. }
  308. public function testRememberLoginValidToken() {
  309. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  310. $session->expects($this->exactly(1))
  311. ->method('set')
  312. ->with($this->callback(function ($key) {
  313. switch ($key) {
  314. case 'user_id':
  315. return true;
  316. default:
  317. return false;
  318. }
  319. }, 'foo'));
  320. $session->expects($this->once())
  321. ->method('regenerateId');
  322. $managerMethods = get_class_methods('\OC\User\Manager');
  323. //keep following methods intact in order to ensure hooks are
  324. //working
  325. $doNotMock = array('__construct', 'emit', 'listen');
  326. foreach ($doNotMock as $methodName) {
  327. $i = array_search($methodName, $managerMethods, true);
  328. if ($i !== false) {
  329. unset($managerMethods[$i]);
  330. }
  331. }
  332. $manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
  333. $backend = $this->getMock('\Test\Util\User\Dummy');
  334. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  335. $user->expects($this->any())
  336. ->method('getUID')
  337. ->will($this->returnValue('foo'));
  338. $user->expects($this->once())
  339. ->method('updateLastLoginTimestamp');
  340. $manager->expects($this->once())
  341. ->method('get')
  342. ->with('foo')
  343. ->will($this->returnValue($user));
  344. //prepare login token
  345. $token = 'goodToken';
  346. \OC::$server->getConfig()->setUserValue('foo', 'login_token', $token, time());
  347. $userSession = $this->getMock(
  348. '\OC\User\Session',
  349. //override, otherwise tests will fail because of setcookie()
  350. array('setMagicInCookie'),
  351. //there are passed as parameters to the constructor
  352. array($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config));
  353. $granted = $userSession->loginWithCookie('foo', $token);
  354. $this->assertSame($granted, true);
  355. }
  356. public function testRememberLoginInvalidToken() {
  357. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  358. $session->expects($this->never())
  359. ->method('set');
  360. $session->expects($this->once())
  361. ->method('regenerateId');
  362. $managerMethods = get_class_methods('\OC\User\Manager');
  363. //keep following methods intact in order to ensure hooks are
  364. //working
  365. $doNotMock = array('__construct', 'emit', 'listen');
  366. foreach ($doNotMock as $methodName) {
  367. $i = array_search($methodName, $managerMethods, true);
  368. if ($i !== false) {
  369. unset($managerMethods[$i]);
  370. }
  371. }
  372. $manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
  373. $backend = $this->getMock('\Test\Util\User\Dummy');
  374. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  375. $user->expects($this->any())
  376. ->method('getUID')
  377. ->will($this->returnValue('foo'));
  378. $user->expects($this->never())
  379. ->method('updateLastLoginTimestamp');
  380. $manager->expects($this->once())
  381. ->method('get')
  382. ->with('foo')
  383. ->will($this->returnValue($user));
  384. //prepare login token
  385. $token = 'goodToken';
  386. \OC::$server->getConfig()->setUserValue('foo', 'login_token', $token, time());
  387. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  388. $granted = $userSession->loginWithCookie('foo', 'badToken');
  389. $this->assertSame($granted, false);
  390. }
  391. public function testRememberLoginInvalidUser() {
  392. $session = $this->getMock('\OC\Session\Memory', array(), array(''));
  393. $session->expects($this->never())
  394. ->method('set');
  395. $session->expects($this->once())
  396. ->method('regenerateId');
  397. $managerMethods = get_class_methods('\OC\User\Manager');
  398. //keep following methods intact in order to ensure hooks are
  399. //working
  400. $doNotMock = array('__construct', 'emit', 'listen');
  401. foreach ($doNotMock as $methodName) {
  402. $i = array_search($methodName, $managerMethods, true);
  403. if ($i !== false) {
  404. unset($managerMethods[$i]);
  405. }
  406. }
  407. $manager = $this->getMock('\OC\User\Manager', $managerMethods, array());
  408. $backend = $this->getMock('\Test\Util\User\Dummy');
  409. $user = $this->getMock('\OC\User\User', array(), array('foo', $backend));
  410. $user->expects($this->never())
  411. ->method('getUID');
  412. $user->expects($this->never())
  413. ->method('updateLastLoginTimestamp');
  414. $manager->expects($this->once())
  415. ->method('get')
  416. ->with('foo')
  417. ->will($this->returnValue(null));
  418. //prepare login token
  419. $token = 'goodToken';
  420. \OC::$server->getConfig()->setUserValue('foo', 'login_token', $token, time());
  421. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  422. $granted = $userSession->loginWithCookie('foo', $token);
  423. $this->assertSame($granted, false);
  424. }
  425. public function testActiveUserAfterSetSession() {
  426. $users = array(
  427. 'foo' => new User('foo', null),
  428. 'bar' => new User('bar', null)
  429. );
  430. $manager = $this->getMockBuilder('\OC\User\Manager')
  431. ->disableOriginalConstructor()
  432. ->getMock();
  433. $manager->expects($this->any())
  434. ->method('get')
  435. ->will($this->returnCallback(function ($uid) use ($users) {
  436. return $users[$uid];
  437. }));
  438. $session = new Memory('');
  439. $session->set('user_id', 'foo');
  440. $userSession = $this->getMockBuilder('\OC\User\Session')
  441. ->setConstructorArgs([$manager, $session, $this->timeFactory, $this->defaultProvider, $this->config])
  442. ->setMethods([
  443. 'validateSession'
  444. ])
  445. ->getMock();
  446. $userSession->expects($this->any())
  447. ->method('validateSession');
  448. $this->assertEquals($users['foo'], $userSession->getUser());
  449. $session2 = new Memory('');
  450. $session2->set('user_id', 'bar');
  451. $userSession->setSession($session2);
  452. $this->assertEquals($users['bar'], $userSession->getUser());
  453. }
  454. public function testTryTokenLoginWithDisabledUser() {
  455. $manager = $this->getMockBuilder('\OC\User\Manager')
  456. ->disableOriginalConstructor()
  457. ->getMock();
  458. $session = new Memory('');
  459. $token = $this->getMock('\OC\Authentication\Token\IToken');
  460. $user = $this->getMock('\OCP\IUser');
  461. $userSession = new \OC\User\Session($manager, $session, $this->timeFactory, $this->defaultProvider, $this->config);
  462. $request = $this->getMock('\OCP\IRequest');
  463. $request->expects($this->once())
  464. ->method('getHeader')
  465. ->with('Authorization')
  466. ->will($this->returnValue('token xxxxx'));
  467. $this->defaultProvider->expects($this->once())
  468. ->method('validateToken')
  469. ->with('xxxxx')
  470. ->will($this->returnValue($token));
  471. $token->expects($this->once())
  472. ->method('getUID')
  473. ->will($this->returnValue('user123'));
  474. $manager->expects($this->once())
  475. ->method('get')
  476. ->with('user123')
  477. ->will($this->returnValue($user));
  478. $user->expects($this->once())
  479. ->method('isEnabled')
  480. ->will($this->returnValue(false));
  481. $this->assertFalse($userSession->tryTokenLogin($request));
  482. }
  483. public function testValidateSessionDisabledUser() {
  484. $userManager = $this->getMock('\OCP\IUserManager');
  485. $session = $this->getMock('\OCP\ISession');
  486. $timeFactory = $this->getMock('\OCP\AppFramework\Utility\ITimeFactory');
  487. $tokenProvider = $this->getMock('\OC\Authentication\Token\IProvider');
  488. $userSession = $this->getMockBuilder('\OC\User\Session')
  489. ->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config])
  490. ->setMethods(['logout'])
  491. ->getMock();
  492. $user = $this->getMock('\OCP\IUser');
  493. $token = $this->getMock('\OC\Authentication\Token\IToken');
  494. $session->expects($this->once())
  495. ->method('getId')
  496. ->will($this->returnValue('sessionid'));
  497. $tokenProvider->expects($this->once())
  498. ->method('getToken')
  499. ->with('sessionid')
  500. ->will($this->returnValue($token));
  501. $session->expects($this->once())
  502. ->method('get')
  503. ->with('last_login_check')
  504. ->will($this->returnValue(1000));
  505. $timeFactory->expects($this->once())
  506. ->method('getTime')
  507. ->will($this->returnValue(5000));
  508. $tokenProvider->expects($this->once())
  509. ->method('getPassword')
  510. ->with($token, 'sessionid')
  511. ->will($this->returnValue('123456'));
  512. $token->expects($this->once())
  513. ->method('getLoginName')
  514. ->will($this->returnValue('User5'));
  515. $userManager->expects($this->once())
  516. ->method('checkPassword')
  517. ->with('User5', '123456')
  518. ->will($this->returnValue(true));
  519. $user->expects($this->once())
  520. ->method('isEnabled')
  521. ->will($this->returnValue(false));
  522. $userSession->expects($this->once())
  523. ->method('logout');
  524. $this->invokePrivate($userSession, 'validateSession', [$user]);
  525. }
  526. public function testValidateSessionNoPassword() {
  527. $userManager = $this->getMock('\OCP\IUserManager');
  528. $session = $this->getMock('\OCP\ISession');
  529. $timeFactory = $this->getMock('\OCP\AppFramework\Utility\ITimeFactory');
  530. $tokenProvider = $this->getMock('\OC\Authentication\Token\IProvider');
  531. $userSession = $this->getMockBuilder('\OC\User\Session')
  532. ->setConstructorArgs([$userManager, $session, $timeFactory, $tokenProvider, $this->config])
  533. ->setMethods(['logout'])
  534. ->getMock();
  535. $user = $this->getMock('\OCP\IUser');
  536. $token = $this->getMock('\OC\Authentication\Token\IToken');
  537. $session->expects($this->once())
  538. ->method('getId')
  539. ->will($this->returnValue('sessionid'));
  540. $tokenProvider->expects($this->once())
  541. ->method('getToken')
  542. ->with('sessionid')
  543. ->will($this->returnValue($token));
  544. $session->expects($this->once())
  545. ->method('get')
  546. ->with('last_login_check')
  547. ->will($this->returnValue(1000));
  548. $timeFactory->expects($this->once())
  549. ->method('getTime')
  550. ->will($this->returnValue(5000));
  551. $tokenProvider->expects($this->once())
  552. ->method('getPassword')
  553. ->with($token, 'sessionid')
  554. ->will($this->throwException(new \OC\Authentication\Exceptions\PasswordlessTokenException()));
  555. $session->expects($this->once())
  556. ->method('set')
  557. ->with('last_login_check', 5000);
  558. $this->invokePrivate($userSession, 'validateSession', [$user]);
  559. }
  560. }