* refactor: version old slots * feat: init new slots endpoints * chore: range format * fix: duratin * fix: duratin * test: slot releaseAt * refactor: reserve slot response * refactor variable name * docs: have new slots controller in docs * feat: crud for slots reservations * refactor: use exclude all for response * docs * chore: slots input service * refactor mini * refactor: remove unused imports * docs * handle orgSlug for dynamic events * refactor: correct name * docs * add optional organizationSlug to BySlug search * refactor: slot output format * refactor: return seated slot info * docs * rename functions * refactor: slots seated response * fix: handle same username in org and non org * refactor: test format * fix: allow reservationDuration only for authed requests * chore: check if auth user has permissions to define custom reservation duration * refactor: split e2e test files * refactor: invalid request exception codes * chore: old slots controller uses all old versions
15 lines
578 B
TypeScript
15 lines
578 B
TypeScript
import { ApiAuthGuard } from "@/modules/auth/guards/api-auth/api-auth.guard";
|
|
import { NO_AUTH_PROVIDED_MESSAGE } from "@/modules/auth/strategies/api-auth/api-auth.strategy";
|
|
|
|
export class OptionalApiAuthGuard extends ApiAuthGuard {
|
|
handleRequest(error: Error, user: any) {
|
|
// note(Lauris): optional means that auth is not required but if it is invalid then still throw error.
|
|
const noAuthProvided = error && error.message === NO_AUTH_PROVIDED_MESSAGE;
|
|
if (user || noAuthProvided || !error) {
|
|
return user || null;
|
|
} else {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|