mirror of
https://github.com/immich-app/immich.git
synced 2026-03-12 05:07:26 +03:00
Add web interface with admin functionality (#167)
This commit is contained in:
44
web/src/routes/admin/api/create-user.ts
Normal file
44
web/src/routes/admin/api/create-user.ts
Normal file
@@ -0,0 +1,44 @@
|
||||
import type { RequestHandler } from '@sveltejs/kit';
|
||||
import { serverEndpoint } from '$lib/constants';
|
||||
|
||||
export const post: RequestHandler = async ({ request, locals }) => {
|
||||
const form = await request.formData();
|
||||
|
||||
const email = form.get('email')
|
||||
const password = form.get('password')
|
||||
const firstName = form.get('firstName')
|
||||
const lastName = form.get('lastName')
|
||||
|
||||
const payload = {
|
||||
email,
|
||||
password,
|
||||
firstName,
|
||||
lastName,
|
||||
}
|
||||
|
||||
const res = await fetch(`${serverEndpoint}/user`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'Authorization': `Bearer ${locals.user?.accessToken}`
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
|
||||
if (res.status === 201) {
|
||||
return {
|
||||
status: 201,
|
||||
body: {
|
||||
success: 'Succesfully create user account'
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
status: 400,
|
||||
body: {
|
||||
error: await res.json()
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user