summaryrefslogtreecommitdiffstats
path: root/docs/password-reset.md
blob: 051895340e25b48db4c5afc5bb1fc6c83eb21052 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# Password Reset Handling

*Gatekeeper* also includes some password reset handling functionality. It doesn't try to send an email or output a web page
with the functionality. Instead, it provides methods to generate and validate a unique code. When the code is generated, it is
added into the user's record and stored for evaluation.

The code will expire in *one hour* from the time it was generated.

```php
<?php
$user = Gatekeeper::findUserById(1);
$code = $user->getResetPasswordCode();

echo 'Your password reset code is: '.$code."\n";

// Now lets verify it...
$code = $_GET['code'];
if ($user->checkResetPasswordCode($code) === true) {
    echo 'valid!';
}
?>
```

If the code is valid, it and the timeout are cleared from the user's record.