Skip to content

Commit

Permalink
LoginForm interface
Browse files Browse the repository at this point in the history
  • Loading branch information
lcharette committed Jun 9, 2024
1 parent dd6d220 commit a58d748
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
5 changes: 3 additions & 2 deletions app/assets/components/Auth/AuthLogin.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
<script setup>
<script setup lang="ts">
import { useLoginApi } from '../../composables/loginApi'
import { useAuthStore } from '../../stores/auth'
import type { LoginForm } from '../../interfaces/loginForm';
// Form variables
let form = {
let form: LoginForm = {
user_name: '',
password: ''
}
Expand Down
1 change: 1 addition & 0 deletions app/assets/composables/authCheckApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export function useCheckApi(auth: typeof authStore) {
auth.setUser(response.data.user)
})
.catch((err) => {
auth.unsetUser()
error.value = {
...err.response.data,
...{ style: AlertStyle.Danger, closeBtn: true }
Expand Down
4 changes: 2 additions & 2 deletions app/assets/composables/loginApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { ref } from 'vue'
import axios from 'axios'
import { type AlertInterface, AlertStyle } from '@userfrosting/theme-pink-cupcake/types'
import { useAuthStore } from '../stores/auth'
import type { LoginForm } from '../interfaces/loginForm';
const authStore = useAuthStore()

/**
Expand All @@ -15,8 +16,7 @@ export function useLoginApi(auth: typeof authStore) {
const error = ref<AlertInterface | undefined>()

// TODO : Error if user is not null
// TODO : Change form type
const login = (form: any) => {
const login = (form: LoginForm) => {
loading.value = true
error.value = undefined
axios
Expand Down
4 changes: 4 additions & 0 deletions app/assets/interfaces/loginForm.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface LoginForm {
user_name: string
password: string
}

0 comments on commit a58d748

Please sign in to comment.