CakeDC\Users\Model\Behavior\RegisterBehavior::validate PHP Method

validate() public method

Validates token and return user
public validate ( type $token, null $callback = null ) : User
$token type toke to be validated.
$callback null function that will be returned.
return CakeDC\Users\Model\Entity\User $user
    public function validate($token, $callback = null)
    {
        $user = $this->_table->find()->select(['token_expires', 'id', 'active', 'token'])->where(['token' => $token])->first();
        if (empty($user)) {
            throw new UserNotFoundException(__d('CakeDC/Users', "User not found for the given token and email."));
        }
        if ($user->tokenExpired()) {
            throw new TokenExpiredException(__d('CakeDC/Users', "Token has already expired user with no token"));
        }
        if (!method_exists($this, $callback)) {
            return $user;
        }
        return $this->_table->{$callback}($user);
    }