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