Login Page with NodeJS

In a NodeJS project I configured a Security Provider in Global with a static list of users and permissions
Then in the API I created a “login” action, a “logout” action and a “user” action

Then for a page to protect, I set “Server Side Data”

Schermata 2021-10-27 alle 21.52.40

The login page was created with the following settings

It all seems correct to me, but obviously I made a mistake because it doesn’t work

Has anyone else had problems setting up security with nodeJS?

None but i always use “database” never static so may be associated with that.

Thanks
Honestly I don’t know if I made the wrong configuration (which seems correct to me) or if I have to change something with static users and permissions

How should the items in this section be managed and configured?
Schermata 2021-10-28 alle 19.32.19

Marzio, maybe explain in details what doesn't work ... are there errors? If yes what errors do you see?
"It doesn't work" really tells us nothing.

Thanks Teodor
A test page automatically opens the login page
If I enter the wrong credentials, the text appears and stays on the login page (and this is fine with me)
If I enter the correct credentials the result is the same
Anyway I started all over again and first of all I’d like to know how I have to modify the starting global action (scrennshoot)
Then I follow your tutorial again, but always with static users and permissions

It doesn’t matter static or database, the logic is the same.

Ok I try again But sorry for a correct action

  • When is Basic Authentication needed?
  • Cookie Option do I have to enter URL?
  • Secure when needed?
  • How should the Same site option be chosen?

You don’t need any of these options and they are not the cause of any issue on your site, related to login.

OK Teodor
Although it would still be interesting, for a better understanding of Wappler, to know what use those rumors have, since they exist
Anyway after dinner I reconfigure the actions and see if I solve
Thanks

Teodor
I think I have followed the steps correctly, with the only variant that in the event of unauthorized entry, the login page remains (with only the warning text displayed)
The Login page provides for redirection to a specific page in case of success.
But I would like the redirect to be to the current page that requested authorization if successful.
I hope it is possible.

However, at the moment I notice an anomaly with the Login page:
If the credentials are incorrect, the alert text appears, but if the credentials are correct, the alert text still appears first and only then accepts and redirects

@Teodor
I checked point by point and now it works.
I don’t know exactly what caused the incorrect credentials message to appear even if successful.
Perhaps in the code the Success event was placed after the Unauthorized event

However I can’t get what I want:

  • First of all, in case of success, I would like the redirect not to lead to a defined page, but to the current page that caused the request for credentials
  • Then I would like that in the Menu (NavBar - Layout page) it was possible to insert the “login” link or the “logout” link according to the status
    Being NodeJS I would like to know if it is possible
    Thanks

Well then don't add redirect on success.

It's the same for all server models. Add conditional regions and show/hide your buttons.

So i can insert links even if in a layout page. Well now I try
Thanks

Maybe I expressed myself badly.
If I remove the redirect after success, the Login page remains.
I would like him instead to return to the page that caused the login request

Then keep the request page in an url parameter / session and use this value to redirect the user on successful login.

1 Like