move oauth api

This commit is contained in:
Henry Jameson 2026-06-17 19:04:05 +03:00
commit d2dcdfbd80
10 changed files with 204 additions and 281 deletions

View file

@ -1,8 +1,8 @@
import oauth from '../../services/new_api/oauth.js'
import { useInstanceStore } from 'src/stores/instance.js'
import { useOAuthStore } from 'src/stores/oauth.js'
import { getToken } from 'src/api/oauth.js'
const oac = {
props: ['code'],
mounted() {
@ -10,18 +10,16 @@ const oac = {
const oauthStore = useOAuthStore()
const { clientId, clientSecret } = oauthStore
oauth
.getToken({
clientId,
clientSecret,
instance: useInstanceStore().server,
code: this.code,
})
.then((result) => {
oauthStore.setToken(result.access_token)
this.$store.dispatch('loginUser', result.access_token)
this.$router.push({ name: 'friends' })
})
getToken({
clientId,
clientSecret,
instance: useInstanceStore().server,
code: this.code,
}).then(({ data: result }) => {
oauthStore.setToken(result.access_token)
this.$store.dispatch('loginUser', result.access_token)
this.$router.push({ name: 'friends' })
})
}
},
}