Last change
on this file since 231918f was 231918f, checked in by Aleksandarj03 <138524804+Aleksandarj03@…>, 3 months ago |
Fixed login with admin
|
-
Property mode
set to
100644
|
File size:
1.6 KB
|
Line | |
---|
1 | <script>
|
---|
2 |
|
---|
3 |
|
---|
4 | import { userStore } from '@/PiniaStores/UserStore.js'
|
---|
5 |
|
---|
6 | import {useRouter} from 'vue-router'
|
---|
7 | import router from '@/router/index.js'
|
---|
8 |
|
---|
9 | export default {
|
---|
10 | data() {
|
---|
11 | return {
|
---|
12 | form_info:{
|
---|
13 | email: '',
|
---|
14 | password: ''
|
---|
15 | },
|
---|
16 |
|
---|
17 | url: 'http://localhost:8080/api/auth/login',
|
---|
18 |
|
---|
19 | userStore_: userStore(),
|
---|
20 |
|
---|
21 | router: useRouter()
|
---|
22 |
|
---|
23 | }
|
---|
24 | },
|
---|
25 | methods: {
|
---|
26 | async makeLogin() {
|
---|
27 |
|
---|
28 | await fetch(this.url, {
|
---|
29 | method: 'POST',
|
---|
30 | headers: { 'Content-Type': 'application/x-www-form-urlencoded'},
|
---|
31 | body: new URLSearchParams({
|
---|
32 | email: this.form_info.email,
|
---|
33 | password: this.form_info.password
|
---|
34 | })
|
---|
35 | }).then((response) => response.json())
|
---|
36 | .then(json => {this.userStore_.setLocalStorage(json);
|
---|
37 | router.push('/')})
|
---|
38 |
|
---|
39 | }
|
---|
40 | }
|
---|
41 | }
|
---|
42 |
|
---|
43 | </script>
|
---|
44 |
|
---|
45 | <template>
|
---|
46 |
|
---|
47 |
|
---|
48 | <div class="container-xxl">
|
---|
49 |
|
---|
50 | <div class="row justify-content-center ">
|
---|
51 | <!-- <form v-on:submit.prevent="makeLogin">-->
|
---|
52 | <!-- <form action="http://localhost:8080/api/auth/login" method="POST">-->
|
---|
53 | <div class="col-3">
|
---|
54 | <form v-on:submit.prevent="makeLogin">
|
---|
55 |
|
---|
56 | <label for="email" class="form-label">Email</label>
|
---|
57 | <input v-model="this.form_info.email" name="email" id="email" class="form-control" type="text">
|
---|
58 |
|
---|
59 | <label for="password" class="form-label">Password</label>
|
---|
60 | <input v-model="this.form_info.password" name="password" id="password" type="password" class="form-control">
|
---|
61 |
|
---|
62 | <button type="submit" class="btn btn-dark mt-2">Login</button>
|
---|
63 | </form>
|
---|
64 | </div>
|
---|
65 |
|
---|
66 |
|
---|
67 |
|
---|
68 | </div>
|
---|
69 |
|
---|
70 |
|
---|
71 | </div>
|
---|
72 | </template>
|
---|
73 |
|
---|
74 | <style scoped>
|
---|
75 |
|
---|
76 | </style>
|
---|
Note:
See
TracBrowser
for help on using the repository browser.