pleroma-fe/src/components/login_form/login_form.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-10-27 00:20:39 +11:00
import oauthApi from '../../services/new_api/oauth.js'
2016-10-28 03:02:41 +11:00
const LoginForm = {
data: () => ({
user: {},
authError: false
2016-10-28 03:02:41 +11:00
}),
computed: {
2018-11-08 02:56:12 +11:00
loginMethod () { return this.$store.state.instance.loginMethod },
loggingIn () { return this.$store.state.users.loggingIn },
2018-09-10 04:21:23 +10:00
registrationOpen () { return this.$store.state.instance.registrationOpen }
2016-10-28 03:02:41 +11:00
},
methods: {
2018-10-27 00:16:23 +11:00
oAuthLogin () {
oauthApi.login({
oauth: this.$store.state.oauth,
instance: this.$store.state.instance.server,
commit: this.$store.commit
2018-10-27 00:20:39 +11:00
})
2018-10-27 00:16:23 +11:00
},
2016-10-28 03:02:41 +11:00
submit () {
2018-11-08 02:56:12 +11:00
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')
})
})
2016-10-28 03:02:41 +11:00
}
}
}
export default LoginForm