Commit aed7f643 authored by Samundra Shrestha's avatar Samundra Shrestha Committed by Tim Neutkens

add extra info to authentication (#6435)

* add extra info to authentication

* Update auth.js
parent 806bfdfa
...@@ -63,12 +63,18 @@ export const withAuthSync = WrappedComponent => ...@@ -63,12 +63,18 @@ export const withAuthSync = WrappedComponent =>
export const auth = ctx => { export const auth = ctx => {
const { token } = nextCookie(ctx) const { token } = nextCookie(ctx)
/*
* This happens on server only, ctx.req is available means it's being
* rendered on server. If we are on server and token is not available,
* means user is not logged in.
*/
if (ctx.req && !token) { if (ctx.req && !token) {
ctx.res.writeHead(302, { Location: '/login' }) ctx.res.writeHead(302, { Location: '/login' })
ctx.res.end() ctx.res.end()
return return
} }
// We already checked for server. This should only happen on client.
if (!token) { if (!token) {
Router.push('/login') Router.push('/login')
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment