aboutsummaryrefslogtreecommitdiff
path: root/src/controllers/PasswordReminderController.php
blob: 0c2a087ae75b38770265d8c2ce96015551d45bad (plain) (blame)
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
<?php
/**
 * Created by PhpStorm.
 * User: camilstaps
 * Date: 13-5-15
 * Time: 13:13
 */

namespace CamilStaps\BotleaguesApi;

use Illuminate\Support\Facades\Input;

class PasswordReminderController extends BaseController {

    protected $passwordReminder;

    public function __construct(PasswordReminder $passwordReminder) {
        $this->passwordReminder = $passwordReminder;
    }

    /**
     * Set the userId and create a random token
     */
    public function store() {
        $this->passwordReminder->userId = Input::get('user_id');
        $this->passwordReminder->token = base64_encode(openssl_random_pseudo_bytes(64));

        if ($this->passwordReminder->save()) {
            return $this->passwordReminder;
        } else {
            throw new \Dingo\Api\Exception\StoreResourceFailedException;
        }
    }

}