Re-activate registration, use oauth password flow to fetch token.
This commit is contained in:
parent
b6cd4ff32a
commit
4d9680e797
3 changed files with 41 additions and 5 deletions
|
@ -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) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue