From 50264410f541c8f9f3416bd0027fc199cb96e424 Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Wed, 7 Nov 2018 16:56:12 +0100 Subject: Add login form back in. --- src/components/login_form/login_form.js | 26 ++++++++++++++++++-------- src/components/login_form/login_form.vue | 19 ++++++++++++++++++- 2 files changed, 36 insertions(+), 9 deletions(-) (limited to 'src/components') diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index ffdd5504..49868aed 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -5,6 +5,7 @@ const LoginForm = { authError: false }), computed: { + loginMethod () { return this.$store.state.instance.loginMethod }, loggingIn () { return this.$store.state.users.loggingIn }, registrationOpen () { return this.$store.state.instance.registrationOpen } }, @@ -17,14 +18,23 @@ const LoginForm = { }) }, submit () { - this.$store.dispatch('loginUser', this.user).then( - () => {}, - (error) => { - this.authError = error - this.user.username = '' - this.user.password = '' - } - ) + const data = { + oauth: this.$store.state.oauth, + instance: this.$store.state.instance.server + } + oauthApi.getOrCreateApp(data).then((app) => { + oauthApi.getTokenWithCredentials( + { + app, + instance: data.instance, + username: this.user.username, + password: this.user.password}) + .then((result) => { + this.$store.commit('setToken', result.access_token) + this.$store.dispatch('loginUser', result.access_token) + this.$router.push('/main/friends') + }) + }) } } } diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue index db389716..8a5174d7 100644 --- a/src/components/login_form/login_form.vue +++ b/src/components/login_form/login_form.vue @@ -5,7 +5,24 @@ {{$t('login.login')}}
- + +