Merge branch 'masto-register-app-secret' into 'develop'

Proper clientId/secret/token caching, MastoAPI registration

Closes #554

See merge request pleroma/pleroma-fe!806
This commit is contained in:
HJ 2019-06-16 11:18:21 +00:00
commit 1db3c785d8
10 changed files with 162 additions and 97 deletions

View file

@ -26,23 +26,30 @@ const LoginForm = {
this.isTokenAuth ? this.submitToken() : this.submitPassword()
},
submitToken () {
oauthApi.login({
const { clientId } = this.oauth
const data = {
clientId,
instance: this.instance.server,
commit: this.$store.commit
}
oauthApi.getOrCreateApp(data)
.then((app) => { oauthApi.login({ ...app, ...data }) })
},
submitPassword () {
const { clientId } = this.oauth
const data = {
clientId,
oauth: this.oauth,
instance: this.instance.server,
commit: this.$store.commit
})
},
submitPassword () {
const data = {
oauth: this.oauth,
instance: this.instance.server
}
this.error = false
oauthApi.getOrCreateApp(data).then((app) => {
oauthApi.getTokenWithCredentials(
{
app,
...app,
instance: data.instance,
username: this.user.username,
password: this.user.password

View file

@ -4,14 +4,16 @@ const oac = {
props: ['code'],
mounted () {
if (this.code) {
const { clientId } = this.$store.state.oauth
oauth.getToken({
app: this.$store.state.oauth,
clientId,
instance: this.$store.state.instance.server,
code: this.code
}).then((result) => {
this.$store.commit('setToken', result.access_token)
this.$store.dispatch('loginUser', result.access_token)
this.$router.push({name: 'friends'})
this.$router.push({ name: 'friends' })
})
}
}