How can I check if a user is logged in via server?
See original GitHub issueI 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:
- Created 5 years ago
- Reactions:2
- Comments:7 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Any update on this?
@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.