|
| 1 | +<template> |
| 2 | + <section class="container"> |
| 3 | + <div> |
| 4 | + <nuxt-link to="/auth/signup">Not a user? Sign-up</nuxt-link> |
| 5 | + </div> |
| 6 | + <div> |
| 7 | + <form @submit.prevent="submit"> |
| 8 | + <label for="usernameTxt">Username:</label> |
| 9 | + <input id="usernameTxt" v-model="email" type="email" /> |
| 10 | + <label for="passwordTxt">Password:</label> |
| 11 | + <input id="passwordTxt" v-model="password" type="password" /> |
| 12 | + <button type="submit">Sign In</button> |
| 13 | + </form> |
| 14 | + <button class="button" @click.prevent="fbGoogleLogin"> |
| 15 | + Google Login |
| 16 | + </button> |
| 17 | + <button class="button" @click.prevent="fbGoogleLogout"> |
| 18 | + Google Logout |
| 19 | + </button> |
| 20 | + </div> |
| 21 | + </section> |
| 22 | +</template> |
| 23 | + |
| 24 | +<script> |
| 25 | +import { mapActions } from 'vuex' |
| 26 | +export default { |
| 27 | + data() { |
| 28 | + return { |
| 29 | + email: '', |
| 30 | + password: '', |
| 31 | + } |
| 32 | + }, |
| 33 | + middleware: ['handle-login-route'], |
| 34 | + methods: { |
| 35 | + ...mapActions('modules/user', ['login']), |
| 36 | + submit() { |
| 37 | + const res = this.$auth |
| 38 | + .signInWithEmailAndPassword(this.email, this.password) |
| 39 | + .catch((error) => { |
| 40 | + console.log(error.message) |
| 41 | + }) |
| 42 | + console.log(res) |
| 43 | + this.$router.push('/edit') |
| 44 | + }, |
| 45 | + /* |
| 46 | + async fbGoogleLogin() { |
| 47 | + const { user } = await this.$auth.signInWithPopup(googleProvider) |
| 48 | + await this.login(user) |
| 49 | + this.$router.push('/protected') |
| 50 | + }, |
| 51 | + async fbGoogleLogout() { |
| 52 | + await this.logout() |
| 53 | + this.$router.push('/') |
| 54 | + }, */ |
| 55 | + }, |
| 56 | +} |
| 57 | +</script> |
| 58 | + |
| 59 | +<style scoped> |
| 60 | +form { |
| 61 | + padding: 16px; |
| 62 | +} |
| 63 | +input[type='text'], |
| 64 | +input[type='password'] { |
| 65 | + width: 100%; |
| 66 | + padding: 12px 20px; |
| 67 | + margin: 8px 0; |
| 68 | + display: inline-block; |
| 69 | + border: 1px solid #ccc; |
| 70 | + box-sizing: border-box; |
| 71 | +} |
| 72 | +/* button { |
| 73 | + background-color: #4CAF50; |
| 74 | + color: white; |
| 75 | + padding: 14px 20px; |
| 76 | + margin: 8px 0; |
| 77 | + border: none; |
| 78 | + cursor: pointer; |
| 79 | + width: 100%; |
| 80 | + } */ |
| 81 | +button:hover { |
| 82 | + opacity: 0.8; |
| 83 | +} |
| 84 | +.container { |
| 85 | + padding: 16px; |
| 86 | + max-width: 400px; |
| 87 | +} |
| 88 | +</style> |
0 commit comments