LM1LC3N7 / nodebb-plugin-private-forum

A NodeBB plugin to lockdown the forum to non-registered users.
MIT License
3 stars 1 forks source link

login redir problem #5

Closed joyhope closed 2 years ago

joyhope commented 2 years ago

I install the plugin it works. but

when i login in , the url redir to xxxx/manifest.webmanifest?loggedin=true. The browser show the json content.

I am using nginx as reverse proxy, is there special config required?

Before I using the plugin , everything is ok.

LM1LC3N7 commented 2 years ago

When you try to log in or when you are logged? Because this plugin should not touch anything when the user is connected to the nodebb forum.

As long a NodeBB is aware of your connection, reverse proxy or not, I should not change anything.

LM1LC3N7 commented 2 years ago

This plugin should print debug messages if the forum is started like this, can you try?

./nodebb dev
joyhope commented 2 years ago

Login is a success. It seems it is related manifest process.

https://serverfault.com/questions/992633/how-to-make-nginx-server-json-files-with-the-type-application-json-instead-of-te

It seems no related to the plugin, but how to properly setup the nginx.

LM1LC3N7 commented 2 years ago

Good to know, thanks for the update!

joyhope commented 2 years ago

I am still unable to solve the plugin. If I disable the plugin,

The login will redir to http://xxx?loggedin=true

When I activate the plugin, it will use ?loggedin=true, and then jump http://xxx/manifest.webmanifest?loggedin=true (It is written in ?loggedin=true Location in header)

It seems the plugin changed the first URL:?loggedin=true behavior, and then the NEW behavior is not processed correctly.

The problem may be related with nodebb plugin arch.

joyhope commented 2 years ago

I also contact nodebb: https://github.com/NodeBB/NodeBB/issues/10258

but I did not understand where is the problem.

joyhope commented 2 years ago

dev log, after login.

2022-02-07T14:36:29.267Z [4567/49233] - verbose: [plugin-nodebb-private-forum] User is logged or URL is allowed (/manifest.webmanifest?loggedin=true), no redirect.
2022-02-07T14:36:29.270Z [4567/49233] - verbose: [plugins/fireHook] filter:manifest.build
2022-02-07T14:36:31.095Z [4567/49233] - verbose: [plugins/fireHook] filter:middleware.autoLocale
2022-02-07T14:36:31.096Z [4567/49233] - verbose: [plugin-nodebb-private-forum] User is logged or URL is allowed (/service-worker.js), no redirect.
LM1LC3N7 commented 2 years ago

As you can see here, the plugin does not block the manifest file. For me this should not cause any trouble. Does it work correctly without the plugin?

joyhope commented 2 years ago

without plugin , it works correct. As I said, after register, it jump to ?loggedIn=true, works. but with plugin in, it also jump to ?loggedIn, but there is a Location in head, it contains web.manifest?loggedIn=True, and than go this page. The flow is stopped.

So I am hard to determine which part is the problem.

On Mon, Feb 7, 2022 at 11:16 PM Louis MILCENT @.***> wrote:

As you can see here, the plugin does not block the manifest file. For me this should not cause any trouble. Does it work correctly without the plugin?

— Reply to this email directly, view it on GitHub https://github.com/LM1LC3N7/nodebb-plugin-private-forum/issues/5#issuecomment-1031579349, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA4Y6UH6NKSGMMBCXKEBDP3UZ7O5ZANCNFSM5NMCCKKQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you authored the thread.Message ID: @.***>

LM1LC3N7 commented 2 years ago

Hello, can you try again with the latest version 1.3.0?

joyhope commented 2 years ago

thank you very much. It works.

joyhope commented 2 years ago

I check your code changing, but I did not understand. It seems you change the solution, previous solution is based on the app init, and then based on the route request. It seems based on the route request is "easy" to understand, but on the route is a little difficult to know the behavior.

joyhope commented 2 years ago

The new version is very succesful. In the previous solution, though chrome F12 , there is always lots of error, but now all the error request is gone. It likes magic.

I am new to nodebb, I have not understand the plugin design in nodebb. Your plugin is a good start.

LM1LC3N7 commented 2 years ago

Great to read the problem is solved. I have found a small part of the solution on the forum, the other one on an existing plugin (and documentation) 😇

I am a beginner too in NodeBB, so feel free to copy the code and study it, if it can help 😊