feat: FRO-2 Implement Login Component (#8)
Reviewed-on: #8 Reviewed-by: lq64 <lq@blackhole.local> Co-authored-by: Janis <janis.e.20@gmx.de> Co-committed-by: Janis <janis.e.20@gmx.de>
This commit is contained in:
@@ -30,6 +30,7 @@
|
||||
style="width: 100%"
|
||||
filled
|
||||
dark
|
||||
type="password"
|
||||
label-color="white"
|
||||
color="white"
|
||||
v-model="password"
|
||||
@@ -60,8 +61,8 @@
|
||||
import { useQuasar } from 'quasar'
|
||||
import { ref } from 'vue'
|
||||
import axios from "axios";
|
||||
import {useAuthStore} from "@/stores/auth.ts";
|
||||
import router from "@/router";
|
||||
import {useUserInfo} from "@/composables/useUserInfo.ts";
|
||||
|
||||
const api = window?.__RUNTIME_CONFIG__?.API_URL;
|
||||
|
||||
@@ -71,14 +72,14 @@ const username = ref(null)
|
||||
const password = ref(null)
|
||||
const inProgress = ref(false)
|
||||
const loginError = ref('')
|
||||
const uInfo = useUserInfo()
|
||||
|
||||
const onSubmit = () => {
|
||||
if (inProgress.value) return
|
||||
inProgress.value = true
|
||||
loginError.value = ''
|
||||
axios.post(`${api}/login`, {username: username.value, password: password.value}).then(response => {
|
||||
const auth = useAuthStore()
|
||||
auth.setToken(response.data.token)
|
||||
axios.post(`${api}/login`, {username: username.value, password: password.value}, {withCredentials: true}).then((response) => {
|
||||
uInfo.setUserInfo(response.data.user.username, response.data.user.id)
|
||||
router.push("/")
|
||||
}).catch(() => {
|
||||
loginError.value = 'Invalid username or password'
|
||||
@@ -107,11 +108,6 @@ const options = {
|
||||
},
|
||||
"polygon": {
|
||||
"sides": 5
|
||||
},
|
||||
"image": {
|
||||
"src": "img/github.svg",
|
||||
"width": 100,
|
||||
"height": 100
|
||||
}
|
||||
},
|
||||
"opacity": {
|
||||
|
||||
Reference in New Issue
Block a user