Redirect to /login on /settings 401 (#295)
Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
0c251ca376
commit
36d5478e74
@ -74,10 +74,22 @@ export function getGetServerSideProps (query, variables = null, notFoundFunc, re
|
|||||||
|
|
||||||
let error = null; let data = null; let props = {}
|
let error = null; let data = null; let props = {}
|
||||||
if (query) {
|
if (query) {
|
||||||
({ error, data } = await client.query({
|
try {
|
||||||
query,
|
({ error, data } = await client.query({
|
||||||
variables: vars
|
query,
|
||||||
}))
|
variables: vars
|
||||||
|
}))
|
||||||
|
} catch (err) {
|
||||||
|
if (err.message === 'you must be logged in') {
|
||||||
|
const callback = process.env.PUBLIC_URL + req.url
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: `/login?callbackUrl=${encodeURIComponent(callback)}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw err
|
||||||
|
}
|
||||||
|
|
||||||
if (error || !data || (notFoundFunc && notFoundFunc(data))) {
|
if (error || !data || (notFoundFunc && notFoundFunc(data))) {
|
||||||
return {
|
return {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user