aboutsummaryrefslogtreecommitdiff
path: root/src/components/login_form/login_form.js
diff options
context:
space:
mode:
authorRoger Braun <roger@rogerbraun.net>2018-11-07 16:56:12 +0100
committerRoger Braun <roger@rogerbraun.net>2018-11-07 16:56:12 +0100
commit50264410f541c8f9f3416bd0027fc199cb96e424 (patch)
tree70596ee399c44bb5052f13d85964e31fa051f04d /src/components/login_form/login_form.js
parentbcbaf5d7ee970a1bd35e05ad12f4dfbb00f4282e (diff)
Add login form back in.
Diffstat (limited to 'src/components/login_form/login_form.js')
-rw-r--r--src/components/login_form/login_form.js26
1 files changed, 18 insertions, 8 deletions
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')
+ })
+ })
}
}
}