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);
}