authentication implementation
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
export default defineEventHandler(async (event) => {
|
||||
const body = await readBody(event);
|
||||
const { public: { apiBase } } = useRuntimeConfig();
|
||||
try {
|
||||
const data = await $fetch(`${apiBase}/auth/login-step-two`, {
|
||||
method: 'POST',
|
||||
body,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
}
|
||||
});
|
||||
setCookie(event, 'token', data.token, {
|
||||
httpOnly: true,
|
||||
secure: true,
|
||||
maxAge: 60 * 60 * 24 * 7, // 1 week
|
||||
path: '/'
|
||||
})
|
||||
return data;
|
||||
} catch (err) {
|
||||
console.log('server err :', err);
|
||||
return err
|
||||
}
|
||||
|
||||
})
|
||||
Reference in New Issue
Block a user