aboutsummaryrefslogtreecommitdiff
path: root/src/components
diff options
context:
space:
mode:
Diffstat (limited to 'src/components')
-rw-r--r--src/components/login_form/login_form.js17
-rw-r--r--src/components/oauth_callback/oauth_callback.js6
2 files changed, 16 insertions, 7 deletions
diff --git a/src/components/login_form/login_form.js b/src/components/login_form/login_form.js
index 0d76af0e..93214646 100644
--- a/src/components/login_form/login_form.js
+++ b/src/components/login_form/login_form.js
@@ -26,23 +26,30 @@ const LoginForm = {
this.isTokenAuth ? this.submitToken() : this.submitPassword()
},
submitToken () {
- oauthApi.login({
- oauth: this.oauth,
+ const { clientId } = this.oauth
+ const data = {
+ clientId,
instance: this.instance.server,
commit: this.$store.commit
- })
+ }
+
+ oauthApi.getOrCreateApp(data)
+ .then((app) => { oauthApi.login({ ...app, ...data }) })
},
submitPassword () {
+ const { clientId } = this.oauth
const data = {
+ clientId,
oauth: this.oauth,
- instance: this.instance.server
+ instance: this.instance.server,
+ commit: this.$store.commit
}
this.error = false
oauthApi.getOrCreateApp(data).then((app) => {
oauthApi.getTokenWithCredentials(
{
- app,
+ ...app,
instance: data.instance,
username: this.user.username,
password: this.user.password
diff --git a/src/components/oauth_callback/oauth_callback.js b/src/components/oauth_callback/oauth_callback.js
index e3d45ee1..2c6ca235 100644
--- a/src/components/oauth_callback/oauth_callback.js
+++ b/src/components/oauth_callback/oauth_callback.js
@@ -4,14 +4,16 @@ const oac = {
props: ['code'],
mounted () {
if (this.code) {
+ const { clientId } = this.$store.state.oauth
+
oauth.getToken({
- app: this.$store.state.oauth,
+ clientId,
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({name: 'friends'})
+ this.$router.push({ name: 'friends' })
})
}
}