Authentication on the server rendering

Hi, I have a really big problem that I did not get an answer for a long time .
You see, I have to use SSR and it is an important issue for me.
Now is there a way to detect if the user is logged in to the rendering server or not?
In fact, the server must render the components of the react according to the user’s login status.
Also, the Client must render the components according to the user’s login status.
And we can easily detect in the client whether the user is logged in or not and render accordingly.
But on the server, how can we find out if this Request is logged in or not ?
In fact, meteor methods for detecting user login status do not work on the server
This is an important issue and in any powerful framework, you can easily check the user login status in each request.

And we have to say that for some reason I just want to use the server-render package

I raised this issue here as well :

In a method (or publication) you just make use of this.userId:

1 Like

I check the user’s login status in Redux and render all components accordingly.
And in Reducer , I defined a method and return userId.
And right after defining the method, I called it and logged the result. But the result was null .
This is while in the method itself, the userId returns correctly.
Please pay attention to my code as well :

 in Redux.js
import { Meteor } from 'meteor/meteor'
if (Meteor.isServer) {
        log_in() {
            // console.log(this.userId); // return userId
            return this.userId;
}'log_in', (error, result) => { 
    console.log(result); // return Null

This method may not be the right and logical way to get the user status on both the server and the client.
The methods were not designed to return only the user’s id


In fact, we need a way to give us a login status for both the server and the client.
Methods only give us a userId when they are called by a Client
But my calling is in Reducer , And the Reducer is loaded in my router and my router is loaded on both the client and the server .
As a result, the call is made once from the client and once from the server.
And we knew that methods do not have access to the user ID when they are called from the server.

And I have to say about subscribe and publishing ,
This is not a logical method either because the subscription only works on the client.
And we can not wait for the client to load and then render on the server side.
And basically the server rendering and the client load should be simultaneous and maybe the server rendering will be faster