Compare commits

...

1 commit

Author SHA1 Message Date
Henry Jameson
ea62a55f75 fix login 2019-03-13 19:00:04 +02:00
2 changed files with 9 additions and 4 deletions

View file

@ -38,6 +38,11 @@ module.exports = {
changeOrigin: true, changeOrigin: true,
cookieDomainRewrite: 'localhost' cookieDomainRewrite: 'localhost'
}, },
'/oauth': {
target,
changeOrigin: true,
cookieDomainRewrite: 'localhost'
},
'/nodeinfo': { '/nodeinfo': {
target, target,
changeOrigin: true, changeOrigin: true,

View file

@ -1,7 +1,7 @@
import {reduce} from 'lodash' import {reduce} from 'lodash'
const getOrCreateApp = ({oauth, instance}) => { const getOrCreateApp = ({oauth, instance}) => {
const url = `${instance}/api/v1/apps` const url = `/api/v1/apps`
const form = new window.FormData() const form = new window.FormData()
form.append('client_name', `PleromaFE_${Math.random()}`) form.append('client_name', `PleromaFE_${Math.random()}`)
@ -34,14 +34,14 @@ const login = (args) => {
}, false) }, false)
// Do the redirect... // Do the redirect...
const url = `${args.instance}/oauth/authorize?${dataString}` const url = `/oauth/authorize?${dataString}`
window.location.href = url window.location.href = url
}) })
} }
const getTokenWithCredentials = ({app, instance, username, password}) => { const getTokenWithCredentials = ({app, instance, username, password}) => {
const url = `${instance}/oauth/token` const url = `/oauth/token`
const form = new window.FormData() const form = new window.FormData()
form.append('client_id', app.client_id) form.append('client_id', app.client_id)
@ -64,7 +64,7 @@ const getToken = ({app, instance, code}) => {
form.append('client_secret', app.client_secret) form.append('client_secret', app.client_secret)
form.append('grant_type', 'authorization_code') form.append('grant_type', 'authorization_code')
form.append('code', code) form.append('code', code)
form.append('redirect_uri', `${window.location.origin}/oauth-callback`) form.append('redirect_uri', `/oauth-callback`)
return window.fetch(url, { return window.fetch(url, {
method: 'POST', method: 'POST',