Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow null tokens and provide immediate failure responses #10

Open
Firehed opened this issue May 4, 2024 · 0 comments
Open

Allow null tokens and provide immediate failure responses #10

Firehed opened this issue May 4, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Firehed
Copy link
Contributor

Firehed commented May 4, 2024

While a null token during auth or registration will never work, allowing it through can result in some ergonomic improvements - especially when using vanilla PHP without a framework:

Before:

$token = $_POST['token'] ?? null;
if ($token === null) {
  // do something
}
try {
  $auth = $snapAuth->verifyAuthToken($token);
} catch (\SnapAuth\ApiError $e) {
  // do something
}

After:

try {
  $auth = $snapAuth->verifyAuthToken($_POST['token'] ?? null);
} catch (\SnapAuth\ApiError $e) {
  // do something
}
@Firehed Firehed added the enhancement New feature or request label May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant