]>
Commit | Line | Data |
---|---|---|
a6ccda0f RBR |
1 | import Vue from 'vue'; |
2 | import AuthService from '../services/auth'; | |
3 | ||
4 | /* global window */ | |
5 | ||
6 | const internals = {}; | |
7 | ||
8 | export default internals.WelcomeComponent = Vue.component('welcome', { | |
9 | template: '<div class="welcome-container">' + | |
10 | '<p>{{message}}</p>' + | |
11 | '<a href="#" v-on:click=initiateLogin v-if=!loggingIn>Login</a>' + | |
12 | '</div>', | |
13 | ||
14 | data() { | |
15 | ||
16 | return { | |
17 | message: 'Welcome to Dasein, a social network with posts that disappear when the conversation stops', | |
18 | loggingIn: false, | |
19 | authService: new AuthService() | |
20 | }; | |
21 | }, | |
22 | ||
23 | methods: { | |
24 | initiateLogin() { | |
25 | ||
26 | this.message = 'Logging you in...'; | |
27 | this.loggingIn = true; | |
28 | ||
29 | this.authService.initiateLogin().then((authData) => { | |
30 | ||
31 | window.location.href = authData.loginUrl; | |
32 | }).catch((err) => { | |
33 | ||
34 | console.error(err); | |
35 | this.message = 'Oh no! There was a problem logging you in.'; | |
36 | }); | |
37 | } | |
38 | } | |
39 | }); |