Password::checkCookieHash()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Class for user password managing
4
 *
5
 * @file      Password.php
6
 *
7
 * PHP version 8.0+
8
 *
9
 * @author    Alexander Yancharuk <alex at itvault dot info>
10
 * @copyright © 2012-2021 Alexander Yancharuk
11
 * @date      Сбт Апр 21 15:49:49 2012
12
 * @license   The BSD 3-Clause License
13
 *            <https://tldrlegal.com/license/bsd-3-clause-license-(revised)>
14
 */
15
16
namespace Veles\Auth;
17
18
use Veles\Model\User;
19
20
/**
21
 * User password managing
22
 * @author  Alexander Yancharuk <alex at itvault dot info>
23
 */
24
class Password
25
{
26
	/**
27
	 * User hash check
28
	 *
29
	 * @param User $user
30
	 * @param $cookie_hash
31
	 * @return bool
32
	 */
33 2
	public static function checkCookieHash(User $user, $cookie_hash)
34
	{
35 2
		return $user->getCookieHash() === $cookie_hash;
36
	}
37
38
	/**
39
	 * User password check in ajax-authentication
40
	 *
41
	 * @param User $user User
42
	 * @param string $password Password retrieved through ajax
43
	 *
44
	 * @deprecated
45
	 *
46
	 * @return bool
47
	 */
48 2
	public static function check(User $user, $password)
49
	{
50 2
		return $user->getHash() === crypt($password, $user->getHash());
51
	}
52
}
53