diff --git a/app/assets/img/incorrect-password.gif b/app/assets/img/incorrect-password.gif new file mode 100644 index 0000000..8ea4b63 Binary files /dev/null and b/app/assets/img/incorrect-password.gif differ diff --git a/app/components/forms/auth/login-form.vue b/app/components/forms/auth/login-form.vue index 3b0a8fc..7b49279 100644 --- a/app/components/forms/auth/login-form.vue +++ b/app/components/forms/auth/login-form.vue @@ -1,9 +1,19 @@ \ No newline at end of file diff --git a/app/components/forms/auth/registration-form.vue b/app/components/forms/auth/registration-form.vue index 2c16f70..a4a98ac 100644 --- a/app/components/forms/auth/registration-form.vue +++ b/app/components/forms/auth/registration-form.vue @@ -5,27 +5,36 @@ const {register} = useAuth(); const username = ref(""); const email = ref(""); +const errorMessage = ref(""); -const handleRegistration = () => { - register(email.value, username.value); +const handleRegistration = async () => { + try { + await register(email.value, username.value); + } catch (error: any) { + console.error(error); + errorMessage.value = error.message; + } } \ No newline at end of file diff --git a/app/composables/useAuth.ts b/app/composables/useAuth.ts index 55bfbc7..6c0fd76 100644 --- a/app/composables/useAuth.ts +++ b/app/composables/useAuth.ts @@ -6,7 +6,16 @@ export const useAuth = () => { baseURL: config.public.apiBase, credentials: 'include', }) - await $api('/api/login', {method: 'POST', body: {email, password}}) + await $api('/api/login', { + method: 'POST', + onResponseError({response}) { + if (response.status === 401) { + throw new Error('INVALID_CREDENTIALS') + } + }, + body: {email, password} + } + ) window.location.href = '/lists' } @@ -15,7 +24,16 @@ export const useAuth = () => { baseURL: config.public.apiBase, credentials: 'include', }) - await $api('/api/register', {method: 'POST', body: {email, username}}) + await $api('/api/register', { + method: 'POST', + onResponseError({response}) { + console.log("wat", response) + if (response.status === 422) { + throw new Error(response._data.message) + } + }, + body: {email, username} + }) await navigateTo('/auth/login') } diff --git a/app/pages/invitations/[token]/accept.vue b/app/pages/invitations/[token]/accept.vue index c8bcafc..6a775aa 100644 --- a/app/pages/invitations/[token]/accept.vue +++ b/app/pages/invitations/[token]/accept.vue @@ -1,26 +1,19 @@ \ No newline at end of file diff --git a/app/types/invitation-status.ts b/app/types/invitation-status.ts new file mode 100644 index 0000000..496e463 --- /dev/null +++ b/app/types/invitation-status.ts @@ -0,0 +1,13 @@ +export enum InviteStatusEnum { + PENDING = "pending", + ACCEPTED = "accepted", + DECLINED = "declined", + NOT_FOUND = "not_found", + FAILED = "failed", +} + +export type InviteStatus = { + message: string + status: InviteStatusEnum +} +