diff --git a/.gitattributes b/.gitattributes index 176a458..94f480d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -* text=auto +* text=auto eol=lf \ No newline at end of file diff --git a/nuxt.config.ts b/nuxt.config.ts index 2d5787d..574b3f9 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -23,6 +23,10 @@ export default defineNuxtConfig({ } }, + runtimeConfig: { + apiBase: 'https://api.pretendo.cc' + }, + css: ['~/assets/css/main.css'], fonts: { diff --git a/src/pages/account/index.vue b/src/pages/account/index.vue new file mode 100644 index 0000000..45a26af --- /dev/null +++ b/src/pages/account/index.vue @@ -0,0 +1,5 @@ + + + account stub page + + diff --git a/src/pages/account/login/index.vue b/src/pages/account/login/index.vue new file mode 100644 index 0000000..2fa873e --- /dev/null +++ b/src/pages/account/login/index.vue @@ -0,0 +1,239 @@ + + + + + + + {{ $t("account.loginForm.login") }} + {{ $t("account.loginForm.detailsPrompt") }} + + {{ $t("account.loginForm.username") }} + + + + {{ $t("account.loginForm.password") }} + + {{ $t("account.loginForm.forgotPassword") }} + + + + + + {{ $t("account.loginForm.login") }} + + {{ $t("account.loginForm.registerPrompt") }} + + + + + + {{ errorMessage }} + + + + + + + + diff --git a/src/server/api/account/login/index.ts b/src/server/api/account/login/index.ts new file mode 100644 index 0000000..d13e0c4 --- /dev/null +++ b/src/server/api/account/login/index.ts @@ -0,0 +1,25 @@ +export default defineEventHandler(async (event) => { + const body = await readBody(event); + const apiResponse = await fetch(`${useRuntimeConfig(event).apiBase}/v1/login`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify({ ...body, grant_type: 'password' }) + }); + const apiJSON = await apiResponse.json(); + + if (!apiResponse.ok) { + setResponseStatus(event, apiResponse.status, apiJSON.error); + event.node.res.end(); + + return; + } + + setCookie(event, 'refresh_token', apiJSON.refresh_token); + setCookie(event, 'access_token', apiJSON.access_token); + setCookie(event, 'token_type', apiJSON.token_type); + + setResponseStatus(event, 200); + event.node.res.end(); +}); diff --git a/src/server/api/account/login/refresh.ts b/src/server/api/account/login/refresh.ts new file mode 100644 index 0000000..25be858 --- /dev/null +++ b/src/server/api/account/login/refresh.ts @@ -0,0 +1 @@ +// TODO: endpoint for refreshing tokens diff --git a/src/server/api/account/register/index.ts b/src/server/api/account/register/index.ts new file mode 100644 index 0000000..7a1488f --- /dev/null +++ b/src/server/api/account/register/index.ts @@ -0,0 +1 @@ +// TODO: registration diff --git a/src/server/tsconfig.json b/src/server/tsconfig.json index b9ed69c..3c6e968 100644 --- a/src/server/tsconfig.json +++ b/src/server/tsconfig.json @@ -1,3 +1,3 @@ { - "extends": "../.nuxt/tsconfig.server.json" + "extends": "../../.nuxt/tsconfig.server.json" }
account stub page
{{ $t("account.loginForm.detailsPrompt") }}
{{ errorMessage }}