From 9af204b293a9c1b15e472423a4badff505fd662a Mon Sep 17 00:00:00 2001 From: Roger Braun Date: Fri, 26 Oct 2018 15:16:23 +0200 Subject: Move login to oauth. --- src/components/login_form/login_form.js | 8 ++++++++ src/components/login_form/login_form.vue | 18 ++---------------- src/components/oauth_callback/oauth_callback.js | 20 ++++++++++++++++++++ src/components/oauth_callback/oauth_callback.vue | 5 +++++ 4 files changed, 35 insertions(+), 16 deletions(-) create mode 100644 src/components/oauth_callback/oauth_callback.js create mode 100644 src/components/oauth_callback/oauth_callback.vue (limited to 'src/components') diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js index 4405fb92..b1899666 100644 --- a/src/components/login_form/login_form.js +++ b/src/components/login_form/login_form.js @@ -1,3 +1,4 @@ +import oauthApi from "../../services/new_api/oauth.js"; const LoginForm = { data: () => ({ user: {}, @@ -8,6 +9,13 @@ const LoginForm = { registrationOpen () { return this.$store.state.instance.registrationOpen } }, methods: { + oAuthLogin () { + oauthApi.login({ + oauth: this.$store.state.oauth, + instance: this.$store.state.instance.server, + commit: this.$store.commit + }); + }, submit () { this.$store.dispatch('loginUser', this.user).then( () => {}, diff --git a/src/components/login_form/login_form.vue b/src/components/login_form/login_form.vue index b7fed48a..aaaca777 100644 --- a/src/components/login_form/login_form.vue +++ b/src/components/login_form/login_form.vue @@ -5,23 +5,9 @@ {{$t('login.login')}}
-
diff --git a/src/components/oauth_callback/oauth_callback.js b/src/components/oauth_callback/oauth_callback.js new file mode 100644 index 00000000..60a15412 --- /dev/null +++ b/src/components/oauth_callback/oauth_callback.js @@ -0,0 +1,20 @@ +import oauth from '../../services/new_api/oauth.js' + +const oac = { + props: ['code'], + mounted () { + if (this.code) { + oauth.getToken({ + app: this.$store.state.oauth, + instance: this.$store.state.instance.server, + code: this.code + }).then((result) => { + this.$store.commit("setToken", result.access_token) + this.$store.dispatch("loginUser", result.access_token) + this.$router.push('/main/friends') + }) + } + } +} + +export default oac diff --git a/src/components/oauth_callback/oauth_callback.vue b/src/components/oauth_callback/oauth_callback.vue new file mode 100644 index 00000000..9c806916 --- /dev/null +++ b/src/components/oauth_callback/oauth_callback.vue @@ -0,0 +1,5 @@ + + + -- cgit v1.2.3-70-g09d2