Function
checkPwAndActivationCode
($db, $userName, $pw, $activationCode)
Source from the content-addressed store, hash-verified
| 37 | } |
| 38 | |
| 39 | function checkPwAndActivationCode($db, $userName, $pw, $activationCode) |
| 40 | { |
| 41 | $success = false; |
| 42 | |
| 43 | if ($response = $db->query( |
| 44 | "SELECT |
| 45 | u.PW_HASH as pwHash, |
| 46 | u.SALT as salt, |
| 47 | u.ACTIVATION_CODE as activationCode |
| 48 | FROM user u |
| 49 | WHERE u.NAME='".addslashes($userName)."'")) { |
| 50 | |
| 51 | $obj = $response->fetch_object(); |
| 52 | if (!$obj) { |
| 53 | return false; |
| 54 | } |
| 55 | $pwHash = hash("sha256", $pw . $obj->salt); |
| 56 | |
| 57 | return $pwHash == $obj->pwHash && $obj->activationCode == $activationCode; |
| 58 | } |
| 59 | return false; |
| 60 | } |
| 61 | ?> |
Tested by
no test coverage detected