Browse Source

Don't attempt to enrich a user object whenever the role is PUBLIC to avoid 403s

pull/4023/head
Andrew Kingston 5 years ago
parent
commit
bdf7b6257a
  1. 7
      packages/client/src/api/auth.js

7
packages/client/src/api/auth.js

@ -24,7 +24,12 @@ export const logIn = async ({ email, password }) => {
export const fetchSelf = async () => {
const user = await API.get({ url: "/api/self" })
if (user?._id) {
return (await enrichRows([user], TableNames.USERS))[0]
if (user.roleId === "PUBLIC") {
// Don't try to enrich a public user as it will 403
return user
} else {
return (await enrichRows([user], TableNames.USERS))[0]
}
} else {
return null
}

Loading…
Cancel
Save