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.

How can I check if a user is logged in via server?

See original GitHub issue

I have a Next.JS application (SSR’d react) and i’d like to check whether there the user is logged in or not. I’ve got Apollo client hooked up and working with Coginto User Pools but for some reason this code here… (which is run on the server) does not return a user. (When i’m definitely logged in)

import { Auth } from 'aws-amplify'

export default () =>
  Auth.currentAuthenticatedUser()
    .then(user => ({
      loggedInUser: user,
    }))
    .catch(() => ({
      loggedInUser: {},
    }))

And i’m calling the function by running:

const { loggedInUser } = await checkLoggedIn()

Is there a better way to check if a user is logged in on the server?

Versions: aws-amplify: 0.4.2-unstable.21 aws-amplify-react: 0.1.48-unstable.21

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
yvescoinpasscommented, Feb 11, 2020

Any update on this?

1reaction
ngocketitcommented, Jan 21, 2019

@powerful23 Thanks for replying! However, I’m thinking and accepting the fact that maybe it’s not possible to do authentication with Amplify on the server while keep it in sync with client. User logs in on client but currently there is no way to keep that same user on the server (e.g, the same access token that can be used to send the request on the server). We can have a different storage on the server but how to keep it in sync with localStorage on client. If the client can send the token in forms of cookies then we may have some hope, otherwise I think it’s not possible.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What's the best way to see logged in users in Windows Server ...
Open the Task-Manager and see the users tab. There you will find a list of users and their status ...
Read more >
How to list users currently logged on to Windows server 2008
Step 1- Open the Command Line Interface by running "cmd" in the run dialog box (Win + R). Step 2- Type query user...
Read more >
Windows 10: Find Who is Logged in - Technipages
Right-click the taskbar, then select “Task Manager“. · Select the “Users” tab. · Details on the users logged into the machine are displayed....
Read more >
Get Users Logged Into Windows Server Remotely
This will check to see if a user is logged on to a server and if specified, log them off. For updated help...
Read more >
How can I check if a user is logged on via Terminal Server?
The above lists all users. You can also check what the user is running with the QPROCESS command: C:\> qprocess <user name>. To...
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