opensupports/server/controllers/user/send-recover-password.php

36 lines
951 B
PHP
Raw Normal View History

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