Merge branch 'fix/onboarding' of https://github.com/Budibase/budibase into fix/onboarding
This commit is contained in:
commit
fb98147ca5
|
@ -8,11 +8,11 @@ export function createAuthStore() {
|
||||||
subscribe: store.subscribe,
|
subscribe: store.subscribe,
|
||||||
checkAuth: async () => {
|
checkAuth: async () => {
|
||||||
const response = await api.get("/api/admin/users/self")
|
const response = await api.get("/api/admin/users/self")
|
||||||
const user = await response.json()
|
if (response.status !== 200) {
|
||||||
if (response.status === 200) {
|
|
||||||
store.update(state => ({ ...state, user }))
|
|
||||||
} else {
|
|
||||||
store.update(state => ({ ...state, user: null }))
|
store.update(state => ({ ...state, user: null }))
|
||||||
|
} else {
|
||||||
|
const user = await response.json()
|
||||||
|
store.update(state => ({ ...state, user }))
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
login: async creds => {
|
login: async creds => {
|
||||||
|
|
|
@ -16,7 +16,9 @@ async function redirect(ctx, method) {
|
||||||
body: ctx.request.body,
|
body: ctx.request.body,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
ctx.body = await response.json()
|
if (response.status !== 200) {
|
||||||
|
ctx.throw(response.status, response.statusText)
|
||||||
|
}
|
||||||
const cookie = response.headers.get("set-cookie")
|
const cookie = response.headers.get("set-cookie")
|
||||||
if (cookie) {
|
if (cookie) {
|
||||||
ctx.set("set-cookie", cookie)
|
ctx.set("set-cookie", cookie)
|
||||||
|
|
Loading…
Reference in New Issue