public function onRestorePassword()
    {
        $rules = [
            'email' => 'required|email|between:6,255'
        ];

        $validation = Validator::make(post(), $rules);
        if ($validation->fails()) {
            throw new ValidationException($validation);
        }

        $user = UserModel::findByEmail(post('email'));
        if (!$user || $user->is_guest) {
            throw new ApplicationException(Lang::get(/*A user was not found with the given credentials.*/'rainlab.user::lang.account.invalid_user'));
        }

        $code = implode('!', [$user->id, $user->getResetPasswordCode()]);

        $link = $this->makeResetUrl($code);

        $data = [
            'name' => $user->name,
            'link' => $link,
            'code' => $code
        ];

        Mail::send('rainlab.user::mail.restore', $data, function($message) use ($user) {
            $message->to($user->email, $user->full_name);
        });
    }
public function onRestorePassword()
    {
        $rules = [
            'email' => 'required|email|between:6,255'
        ];

        $validation = Validator::make(post(), $rules);
        if ($validation->fails()) {
            throw new ValidationException($validation);
        }

        $user = UserModel::findByEmail(post('email'));
        if (!$user || $user->is_guest) {
            throw new ApplicationException(Lang::get(/*A user was not found with the given credentials.*/'rainlab.user::lang.account.invalid_user'));
        }

        $code = implode('!', [$user->id, $user->getResetPasswordCode()]);

        $link = $this->makeResetUrl($code);

        $data = [
            'name' => $user->name,
            'link' => $link,
            'code' => $code
        ];

        Mail::send('rainlab.user::mail.restore', $data, function($message) use ($user) {
            $message->to($user->email, $user->full_name);
        });
    }
public function onRestorePassword ( ) { $ rules = [ 'email' => 'required|email|between:6,255' ] ; $ validation = Validator :: make ( post ( ) , $ rules ) ; if ( $ validation -> fails ( ) ) { throw new ValidationException ( $ validation ) ; } $ user = UserModel :: findByEmail ( post ( 'email' ) ) ; if ( ! $ user || $ user -> is_guest ) { throw new ApplicationException ( Lang :: get ( /*A user was not found with the given credentials.*/ 'rainlab.user::lang.account.invalid_user' ) ) ; } $ code = implode ( '!' , [ $ user -> id , $ user -> getResetPasswordCode ( ) ] ) ; $ link = $ this -> makeResetUrl ( $ code ) ; $ data = [ 'name' => $ user -> name , 'link' => $ link , 'code' => $ code ] ; Mail :: send ( 'rainlab.user::mail.restore' , $ data , function ( $ message ) use ( $ user ) { $ message -> to ( $ user -> email , $ user -> full_name ) ; } ) ; }
Trigger the password reset email
Trigger the password reset email