question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Pass 'is logged on' info to frontend

See original GitHub issue

On BE req.isAuthenticated() tells me if the user is logged in, but I need to propagate this information to frontend. I noticed there is an admin route: src/routes/admin/index.js:

const isAdmin = false;

...
  async action() {
      if (!isAdmin) { // Redirect to login page if user is not admin
        return { redirect: '/login' };
      }

      ...
  },

but as you can see, the isAdmin bool is always set to false. (I also need this info on FE to display logout button, etc)

Whats the best way to go about doing this?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
frenzzycommented, Jan 9, 2017

@Jaikant why not, you may add actions/reducers to update any data in your store including user, it is up to you. User info presented in store here: (feature/redux branch) src/server.js#L94

0reactions
Jaikantcommented, Jan 9, 2017

@frenzzy any reason for not using a redux action/reducer to update the user information into the store? I guess because of this, the user information is not present on client redux store. Is this intentional and not needed?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How I could pass user data from back to frontend?
I made a YelpCamp clone ony with node and EJS but I'm trying to convert to a Node-React project and was working until...
Read more >
Passing the User Id to the Frontend in MEAN Stack - Javatpoint
Passing the User Id to the Frontend in MEAN Stack · 1) We will go back to our js file, where we create...
Read more >
Passing Data Between Frontend and Backend | Node.js
In this beginner tutorial, I run through frontend (client-side) to backend (server) communication. We look at all the different ways to send ...
Read more >
Backend For Frontend Authentication Pattern with Auth0 and ...
The user can log in with their username and password, social provider, or any other identity provider. Once the user has logged in,...
Read more >
Logging in Browser. Using a structured logger in your…
Logs must be serializable. Logs must be available in production. Given all of the above, what is the best way to log in...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found