2016-07-20 23:38:20 +02:00
|
|
|
<?php
|
2016-07-21 01:39:36 +02:00
|
|
|
use Respect\Validation\Validator as DataValidator;
|
2016-08-04 21:01:24 +02:00
|
|
|
DataValidator::with('CustomValidations', true);
|
2016-07-20 23:38:20 +02:00
|
|
|
|
|
|
|
class SendRecoverPasswordController extends Controller {
|
2016-07-22 09:44:55 +02:00
|
|
|
const PATH = '/send-recover-password';
|
2016-07-20 23:38:20 +02:00
|
|
|
|
|
|
|
public function validations() {
|
|
|
|
return [
|
|
|
|
'permission' => 'any',
|
2016-07-21 01:39:36 +02:00
|
|
|
'requestData' => [
|
|
|
|
'email' => [
|
2016-08-04 21:01:24 +02:00
|
|
|
'validation' => DataValidator::email()->userEmail(),
|
2016-07-21 01:39:36 +02:00
|
|
|
'error' => ERRORS::INVALID_EMAIL
|
|
|
|
]
|
|
|
|
]
|
2016-07-20 23:38:20 +02:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
public function handler() {
|
2016-07-21 01:39:36 +02:00
|
|
|
$email = Controller::request('email');
|
2016-07-20 23:38:20 +02:00
|
|
|
|
2016-07-21 01:39:36 +02:00
|
|
|
$token = Hashing::generateRandomToken();
|
2016-07-20 23:38:20 +02:00
|
|
|
|
2016-07-21 01:39:36 +02:00
|
|
|
$recoverPassword = new RecoverPassword();
|
|
|
|
$recoverPassword->setProperties(array(
|
|
|
|
'email' => $email,
|
|
|
|
'token' => $token
|
|
|
|
));
|
|
|
|
$recoverPassword->store();
|
2016-07-20 23:38:20 +02:00
|
|
|
|
2016-07-21 01:39:36 +02:00
|
|
|
Response::respondSuccess();
|
|
|
|
//TODO: mandar mail con token
|
2016-07-20 23:38:20 +02:00
|
|
|
}
|
2016-07-21 01:39:36 +02:00
|
|
|
}
|