]> git.r.bdr.sh - rbdr/dasein/blame - app/components/login.js
🔧 Update version in package.json
[rbdr/dasein] / app / components / login.js
CommitLineData
a6ccda0f
RBR
1import Vue from 'vue';
2import AuthService from '../services/auth';
3
4const internals = {};
5
6export default internals.LoginComponent = Vue.component('login', {
7 template: '<div class="login-container">' +
8 '<p>{{message}}</p>' +
9 '</div>',
10
11 props: ['oAuthToken', 'oAuthVerifier'],
12
13 data() {
14
15 return {
16 message: 'Logging you in... Wait a sec.',
17 authService: new AuthService()
18 };
19 },
20 methods: {
21 login() {
22
23 if (this.authService.authenticated) {
24 return this.$router.push('/');
25 }
26
27 return this.authService.getUserObject(this.oAuthToken, this.oAuthVerifier).then((response) => {
28
29 console.log(response);
30
31 return this.authService.login(response.user, response.token, response.expiresAt);
32 }).then(() => {
33
34 this.$router.push('/');
35 }).catch((err) => {
36
37 console.error(err);
38 this.message = 'Oh no! There was a problem logging you in.';
39 });
40 }
41 },
42 mounted: function mounted() {
43
44 this.login();
45 }
46});