mirror of
https://github.com/pocket-id/pocket-id.git
synced 2026-05-15 01:19:53 +00:00
feat: return not found. on /setup if already completed
This commit is contained in:
@@ -123,6 +123,10 @@ export default class UserService extends APIService {
|
||||
return res.data as User;
|
||||
};
|
||||
|
||||
checkInitialUserSetupAvailable = async () => {
|
||||
await this.api.get('/signup/setup');
|
||||
};
|
||||
|
||||
listSignupTokens = async (options?: ListRequestOptions) => {
|
||||
const res = await this.api.get('/signup-tokens', { params: options });
|
||||
return res.data as Paginated<SignupToken>;
|
||||
|
||||
18
frontend/src/routes/signup/setup/+page.ts
Normal file
18
frontend/src/routes/signup/setup/+page.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
import { error } from '@sveltejs/kit';
|
||||
import UserService from '$lib/services/user-service';
|
||||
import { AxiosError } from 'axios';
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async () => {
|
||||
const userService = new UserService();
|
||||
|
||||
try {
|
||||
await userService.checkInitialUserSetupAvailable();
|
||||
} catch (e) {
|
||||
if (e instanceof AxiosError && e.response?.status === 404) {
|
||||
error(404, 'Not found');
|
||||
}
|
||||
|
||||
throw e;
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user