-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathReset_password.controller.php
More file actions
46 lines (35 loc) · 920 Bytes
/
Copy pathReset_password.controller.php
File metadata and controls
46 lines (35 loc) · 920 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* Reset-password API endpoint controller.
* Ex: reset-password?c=[code from email]&p=[new password]
* Written by Bradley Gill
* altered effect (http://alteredeffect.com)
* bradgill@gmail.com
*/
class Reset_password extends Controller {
// Reset the password
public function get( $chunks ) {
return $this->reset();
}
// Reset the password
public function post( $chunks ) {
return $this->reset();
}
public function put( $chunks ) {
Controller::error( 405, 'Not applicable.');
}
public function delete( $chunks ) {
Controller::error( 405, 'Not applicable.');
}
private function reset() {
global $database;
$c = get( $_REQUEST, 'c', '' );
$p = get( $_REQUEST, 'p', '' );
$un = new UserManager( $database );
if ( $un->resetPassword( $c, $p ) ) {
return 'Your password has been reset.';
}
Controller::error( 400, 'Invalid reset request' );
}
}
?>