|
34 | 34 | Login
|
35 | 35 | </v-btn>
|
36 | 36 | <v-btn
|
37 |
| - @click="login" |
| 37 | + @click="register" |
38 | 38 | >
|
39 | 39 | Sign Up
|
40 | 40 | </v-btn>
|
|
82 | 82 | </template>
|
83 | 83 | <script>
|
84 | 84 | export default {
|
85 |
| - mounted () { |
| 85 | + mounted() { |
86 | 86 | this.$auth.logout();
|
87 | 87 | this.$auth.state("/realtime-database", "/login").then(user => {
|
88 | 88 | if (!user) {
|
89 | 89 | this.ready = false;
|
90 | 90 | }
|
91 | 91 | });
|
92 | 92 | },
|
93 |
| - data () { |
| 93 | + data() { |
94 | 94 | return {
|
95 | 95 | snackbar: false,
|
96 | 96 | email: "",
|
97 | 97 | password: "",
|
98 | 98 | error: "",
|
99 | 99 | ready: false,
|
100 | 100 | emailRules: [
|
101 |
| - v => !!v || 'E-mail is required', |
102 |
| - v => /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) || 'E-mail must be valid' |
| 101 | + v => !!v || "E-mail is required", |
| 102 | + v => |
| 103 | + /^\w+([.-]?\w+)*@\w+([.-]?\w+)*(\.\w{2,3})+$/.test(v) || |
| 104 | + "E-mail must be valid" |
103 | 105 | ],
|
104 | 106 | e3: true
|
105 | 107 | };
|
106 | 108 | },
|
107 | 109 | computed: {},
|
108 | 110 | methods: {
|
109 |
| - login () { |
110 |
| - this.ready = true |
111 |
| - this.$auth.logout() |
| 111 | + login() { |
| 112 | + this.ready = true; |
| 113 | + this.$auth.logout(); |
112 | 114 | this.$auth
|
113 | 115 | .loginWithEmailAndPassword(this.email, this.password)
|
114 | 116 | .then(user => {
|
115 |
| - this.ready = false |
| 117 | + this.ready = false; |
116 | 118 | })
|
117 | 119 | .catch(error => {
|
118 |
| - this.snackbar = true |
119 |
| - this.ready = false |
120 |
| - this.error = error.message |
| 120 | + this.snackbar = true; |
| 121 | + this.ready = false; |
| 122 | + this.error = error.message; |
121 | 123 | });
|
122 | 124 | },
|
123 |
| - register () { |
| 125 | + register() { |
124 | 126 | this.ready = true;
|
125 | 127 | this.$auth
|
126 | 128 | .registerWithEmailAndPassword(this.email, this.password)
|
127 | 129 | .then(user => {
|
128 |
| - this.ready = false |
| 130 | + this.ready = false; |
129 | 131 | })
|
130 | 132 | .catch(error => {
|
131 |
| - this.error = error.message |
132 |
| - this.ready = false |
133 |
| - this.snackbar = true |
| 133 | + this.error = error.message; |
| 134 | + this.ready = false; |
| 135 | + this.snackbar = true; |
134 | 136 | });
|
135 | 137 | },
|
136 |
| - signInGoogle () { |
137 |
| - this.ready = true |
| 138 | + signInGoogle() { |
| 139 | + this.ready = true; |
138 | 140 | this.$auth
|
139 | 141 | .signInWithGoogle()
|
140 | 142 | .then(result => {
|
141 | 143 | // This gives you the Google's Access Token. You can use it to access the Google API.
|
142 | 144 | // console.log("Token : " + result.credential.accessToken)
|
143 | 145 | // The signed-in user info.
|
144 | 146 | // console.log("User Email : " + result.user.email)
|
145 |
| - this.ready = false |
| 147 | + this.ready = false; |
146 | 148 | })
|
147 | 149 | .catch(error => {
|
148 |
| - this.error = error.message |
149 |
| - this.ready = false |
150 |
| - this.snackbar = true |
151 |
| -
|
| 150 | + this.error = error.message; |
| 151 | + this.ready = false; |
| 152 | + this.snackbar = true; |
152 | 153 | });
|
153 | 154 | },
|
154 |
| - signInFacebook () { |
155 |
| - this.ready = true |
| 155 | + signInFacebook() { |
| 156 | + this.ready = true; |
156 | 157 | this.$auth
|
157 | 158 | .signInWithFacebook()
|
158 | 159 | .then(result => {
|
159 |
| - this.ready = false |
| 160 | + this.ready = false; |
160 | 161 | })
|
161 | 162 | .catch(error => {
|
162 |
| - this.error = error.message |
163 |
| - this.ready = false |
164 |
| - this.snackbar = true |
| 163 | + this.error = error.message; |
| 164 | + this.ready = false; |
| 165 | + this.snackbar = true; |
165 | 166 | });
|
166 | 167 | },
|
167 |
| - signInTwitter () { |
168 |
| - this.ready = true |
| 168 | + signInTwitter() { |
| 169 | + this.ready = true; |
169 | 170 | this.$auth
|
170 | 171 | .signInWithTwitter()
|
171 | 172 | .then(result => (this.ready = false))
|
172 | 173 | .catch(error => {
|
173 |
| - this.error = error.message |
174 |
| - this.ready = false |
175 |
| - this.snackbar = true |
| 174 | + this.error = error.message; |
| 175 | + this.ready = false; |
| 176 | + this.snackbar = true; |
176 | 177 | });
|
177 | 178 | },
|
178 |
| - signInGithub () { |
179 |
| - this.ready = true |
| 179 | + signInGithub() { |
| 180 | + this.ready = true; |
180 | 181 | this.$auth
|
181 | 182 | .signInWithGithub()
|
182 | 183 | .then(result => (this.ready = false))
|
183 | 184 | .catch(error => {
|
184 |
| - this.error = error.message |
185 |
| - this.ready = false |
186 |
| - this.snackbar = true |
| 185 | + this.error = error.message; |
| 186 | + this.ready = false; |
| 187 | + this.snackbar = true; |
187 | 188 | });
|
188 | 189 | },
|
189 |
| - clear () { |
190 |
| - this.$refs.form.reset() |
| 190 | + clear() { |
| 191 | + this.$refs.form.reset(); |
191 | 192 | }
|
192 | 193 | }
|
193 | 194 | };
|
194 | 195 | </script>
|
195 | 196 |
|
196 | 197 |
|
197 | 198 | <style scoped>
|
198 |
| - .push-down { |
199 |
| - margin-top: 15px; |
200 |
| - } |
| 199 | +.push-down { |
| 200 | + margin-top: 15px; |
| 201 | +} |
201 | 202 |
|
202 |
| - .icon { |
203 |
| - height: 18px; |
204 |
| - width: 18px; |
205 |
| - margin-right: 8px; |
206 |
| - } |
207 |
| - .mdl-layout { |
208 |
| - align-items: center; |
209 |
| - justify-content: center; |
210 |
| - } |
211 |
| - .mdl-layout__content { |
212 |
| - padding: 24px; |
213 |
| - flex: none; |
214 |
| - } |
| 203 | +.icon { |
| 204 | + height: 18px; |
| 205 | + width: 18px; |
| 206 | + margin-right: 8px; |
| 207 | +} |
| 208 | +.mdl-layout { |
| 209 | + align-items: center; |
| 210 | + justify-content: center; |
| 211 | +} |
| 212 | +.mdl-layout__content { |
| 213 | + padding: 24px; |
| 214 | + flex: none; |
| 215 | +} |
215 | 216 |
|
216 |
| - .facebook { |
217 |
| - background: #3b5998 !important; |
218 |
| - color: white; |
219 |
| - width: 100%; |
220 |
| - } |
| 217 | +.facebook { |
| 218 | + background: #3b5998 !important; |
| 219 | + color: white; |
| 220 | + width: 100%; |
| 221 | +} |
221 | 222 |
|
222 |
| - .github { |
223 |
| - background: black !important; |
224 |
| - color: #fff; |
225 |
| - width: 100%; |
226 |
| - } |
| 223 | +.github { |
| 224 | + background: black !important; |
| 225 | + color: #fff; |
| 226 | + width: 100%; |
| 227 | +} |
227 | 228 |
|
228 |
| - .twitter { |
229 |
| - background: #1da1f2 !important; |
230 |
| - color: #fff; |
231 |
| - width: 100%; |
232 |
| - } |
| 229 | +.twitter { |
| 230 | + background: #1da1f2 !important; |
| 231 | + color: #fff; |
| 232 | + width: 100%; |
| 233 | +} |
233 | 234 |
|
234 |
| - .google { |
235 |
| - background: #727272 !important; |
236 |
| - color: #fff; |
237 |
| - width: 100%; |
238 |
| - } |
| 235 | +.google { |
| 236 | + background: #727272 !important; |
| 237 | + color: #fff; |
| 238 | + width: 100%; |
| 239 | +} |
239 | 240 | </style>
|
0 commit comments