aboutsummaryrefslogtreecommitdiff
path: root/app/components/login.js
diff options
context:
space:
mode:
authorBen Beltran <ben@nsovocal.com>2017-01-31 00:53:36 -0600
committerBen Beltran <ben@nsovocal.com>2017-01-31 00:53:36 -0600
commita3f9e2603dfdf8c492ec0dc355cd434fc6100f06 (patch)
tree52c84831a3a6070e3e01c5ada5b862fd56f28327 /app/components/login.js
parent7eb26514c478cfa06a797e9d63a29ef6a6d16d59 (diff)
parentf74591da2d5c42b8a1e658d17310e604bedcf856 (diff)
Merge branch 'release/1.0.0'HEADmain
Diffstat (limited to 'app/components/login.js')
-rw-r--r--app/components/login.js46
1 files changed, 46 insertions, 0 deletions
diff --git a/app/components/login.js b/app/components/login.js
new file mode 100644
index 0000000..d900c72
--- /dev/null
+++ b/app/components/login.js
@@ -0,0 +1,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();
+ }
+});