mirror of
https://github.com/samsonjs/immich.git
synced 2026-04-27 15:07:45 +00:00
* Added album page * Refactor sidebar * Added album assets count info * Added album viewer page * Refactor album sorting * Fixed incorrectly showing selected asset in album selection * Improve fetching speed with prefetch * Refactor to use ImmichThubmnail component for all * Update to the latest version of Svelte * Implement fixed app bar in album viewer * Added shared user avatar * Correctly get all owned albums, including shared
59 lines
1.3 KiB
TypeScript
59 lines
1.3 KiB
TypeScript
import type { RequestHandler } from '@sveltejs/kit';
|
|
import * as cookie from 'cookie';
|
|
import { api } from '@api';
|
|
|
|
export const POST: RequestHandler = async ({ request }) => {
|
|
const form = await request.formData();
|
|
|
|
const email = form.get('email');
|
|
const password = form.get('password');
|
|
|
|
try {
|
|
const { data: authUser } = await api.authenticationApi.login({
|
|
email: String(email),
|
|
password: String(password)
|
|
});
|
|
|
|
return {
|
|
status: 200,
|
|
body: {
|
|
user: {
|
|
id: authUser.userId,
|
|
accessToken: authUser.accessToken,
|
|
firstName: authUser.firstName,
|
|
lastName: authUser.lastName,
|
|
isAdmin: authUser.isAdmin,
|
|
email: authUser.userEmail,
|
|
shouldChangePassword: authUser.shouldChangePassword
|
|
},
|
|
success: 'success'
|
|
},
|
|
headers: {
|
|
'Set-Cookie': cookie.serialize(
|
|
'session',
|
|
JSON.stringify({
|
|
id: authUser.userId,
|
|
accessToken: authUser.accessToken,
|
|
firstName: authUser.firstName,
|
|
lastName: authUser.lastName,
|
|
isAdmin: authUser.isAdmin,
|
|
email: authUser.userEmail
|
|
}),
|
|
{
|
|
path: '/',
|
|
httpOnly: true,
|
|
sameSite: 'strict',
|
|
maxAge: 60 * 60 * 24 * 30
|
|
}
|
|
)
|
|
}
|
|
};
|
|
} catch (error) {
|
|
return {
|
|
status: 400,
|
|
body: {
|
|
error: 'Incorrect email or password'
|
|
}
|
|
};
|
|
}
|
|
};
|