formatting
This commit is contained in:
parent
77655c779d
commit
368cb53528
@ -6,6 +6,8 @@ import { PERMISSIONS } from '$lib/consts';
|
||||
import type { Application } from '$lib/types';
|
||||
|
||||
export const load: PageServerLoad = async ({ params, cookies }) => {
|
||||
|
||||
// Permission check (apply perm)
|
||||
const id = parseInt(params.posting);
|
||||
const perms = getUserPerms(cookies);
|
||||
if (perms >= 0 && (perms & PERMISSIONS.APPLY_FOR_JOBS) > 0) {
|
||||
@ -17,7 +19,9 @@ export const load: PageServerLoad = async ({ params, cookies }) => {
|
||||
};
|
||||
|
||||
export const actions: Actions = {
|
||||
// Application submission
|
||||
submit: async ({ request, cookies, params }) => {
|
||||
// Permission check (apply perm)
|
||||
if (!((getUserPerms(cookies) & PERMISSIONS.APPLY_FOR_JOBS) > 0)) {
|
||||
return fail(403, { errorMessage: 'Unauthorized' });
|
||||
}
|
||||
@ -28,9 +32,12 @@ export const actions: Actions = {
|
||||
const postingId = parseInt(params.posting!);
|
||||
const userId = getUserId(cookies);
|
||||
|
||||
// Statement data validation
|
||||
if (!candidateStatement || candidateStatement === '') {
|
||||
return fail(400, { errorMessage: 'Candidate statement is required' });
|
||||
}
|
||||
|
||||
// Push to DB and redirect
|
||||
await createApplication(<Application>{ userId, postingId, candidateStatement });
|
||||
redirect(301, `/postings`);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user