From 4d9680e79734c38cbc0343053523fbdccb002f6e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 6 Nov 2018 21:48:05 +0100 Subject: Re-activate registration, use oauth password flow to fetch token. --- src/components/registration/registration.js | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'src/components/registration/registration.js') diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index 8f59878d..cdcc33c9 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -1,3 +1,5 @@ +import oauthApi from '../../services/new_api/oauth.js' + const registration = { data: () => ({ user: {}, @@ -25,9 +27,22 @@ const registration = { this.$store.state.api.backendInteractor.register(this.user).then( (response) => { if (response.ok) { - this.$store.dispatch('loginUser', this.user) - this.$router.push('/main/all') - this.registering = false + 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') + }) + }) } else { this.registering = false response.json().then((data) => { -- cgit v1.2.3-70-g09d2 From bcbaf5d7ee970a1bd35e05ad12f4dfbb00f4282e Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Tue, 6 Nov 2018 21:51:22 +0100 Subject: Linting. --- src/components/registration/registration.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/components/registration/registration.js') diff --git a/src/components/registration/registration.js b/src/components/registration/registration.js index cdcc33c9..f7f8a720 100644 --- a/src/components/registration/registration.js +++ b/src/components/registration/registration.js @@ -33,10 +33,11 @@ const registration = { } oauthApi.getOrCreateApp(data).then((app) => { oauthApi.getTokenWithCredentials( - {app, - instance: data.instance, - username: this.user.username, - password: this.user.password}) + { + 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) -- cgit v1.2.3-70-g09d2