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

27 lines
673 B
JavaScript
Raw Normal View History

2018-10-26 15:16:23 +02:00
import oauth from '../../services/new_api/oauth.js'
2025-03-11 18:48:55 -04:00
import { useOAuthStore } from 'src/stores/oauth.js'
2018-10-26 15:16:23 +02:00
const oac = {
props: ['code'],
2026-01-06 16:22:52 +02:00
mounted() {
2018-10-26 15:16:23 +02:00
if (this.code) {
2025-03-11 18:48:55 -04:00
const oauthStore = useOAuthStore()
const { clientId, clientSecret } = oauthStore
2026-01-06 16:22:52 +02:00
oauth
.getToken({
clientId,
clientSecret,
instance: this.$store.state.instance.server,
code: this.code,
})
.then((result) => {
oauthStore.setToken(result.access_token)
this.$store.dispatch('loginUser', result.access_token)
this.$router.push({ name: 'friends' })
})
2018-10-26 15:16:23 +02:00
}
2026-01-06 16:22:52 +02:00
},
2018-10-26 15:16:23 +02:00
}
export default oac