source: ReserveNGo-frontend/src/components/Project/login_.vue

Last change on this file was dad25fc, checked in by Aleksandarj03 <138524804+Aleksandarj03@…>, 37 hours ago

Rewrote logic for login and register and added Add Restaurant functionality for the admin

  • Property mode set to 100644
File size: 1.6 KB
RevLine 
[17bf12d]1<script>
2
3
4import { userStore } from '@/PiniaStores/UserStore.js'
5
[2a2614e]6import {useRouter} from 'vue-router'
7import router from '@/router/index.js'
8
[17bf12d]9export 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
[2a2614e]21 router: useRouter()
22
[17bf12d]23 }
24 },
25 methods: {
[2a2614e]26 async makeLogin() {
[17bf12d]27
28 await fetch(this.url, {
29 method: 'POST',
[dad25fc]30 headers: { 'Content-Type': 'application/json'},
31 body: JSON.stringify({
32 email: this.form_info.email,
33 password: this.form_info.password,
[17bf12d]34 })
35 }).then((response) => response.json())
[2a2614e]36 .then(json => {this.userStore_.setLocalStorage(json);
37 router.push('/')})
[17bf12d]38
[2a2614e]39 }
[17bf12d]40 }
41}
[590f667]42
43</script>
44
45<template>
[f9ef3e8]46
47
48 <div class="container-xxl">
49
50 <div class="row justify-content-center ">
[2a2614e]51<!-- <form v-on:submit.prevent="makeLogin">-->
[17bf12d]52<!-- <form action="http://localhost:8080/api/auth/login" method="POST">-->
[f9ef3e8]53 <div class="col-3">
[17bf12d]54 <form v-on:submit.prevent="makeLogin">
[f9ef3e8]55
[17bf12d]56 <label for="email" class="form-label">Email</label>
[231918f]57 <input v-model="this.form_info.email" name="email" id="email" class="form-control" type="text">
[f9ef3e8]58
59 <label for="password" class="form-label">Password</label>
[17bf12d]60 <input v-model="this.form_info.password" name="password" id="password" type="password" class="form-control">
[f9ef3e8]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>
[590f667]72</template>
73
74<style scoped>
75
76</style>
Note: See TracBrowser for help on using the repository browser.