Tzahi12345 / YoutubeDL-Material

Self-hosted YouTube downloader built on Material Design
MIT License
2.61k stars 269 forks source link

[BUG] Can't Login in with Multiuser mode (Login Failed - Unknown Error) #813

Closed duk242 closed 1 year ago

duk242 commented 1 year ago

Ahoy, I'm getting "Login Failed - Unknown Error" when trying to log in.

I'm using Docker on TrueNAS (via the TrueCharts Plugin) Running Version 4.3

If I set it up without multiuser mode on, everything works fine. As soon as I enable multi-user, it has the problem again. Looking in the logs I've got this (just after the admin user is created and I try to log in)

2023-01-08 07:11:58.564525+00:002023-01-08T07:11:58.562Z VERBOSE: New user created: admin 2023-01-08 07:12:03.673164+00:00Error: "exp" should be a number of seconds 2023-01-08 07:12:03.673234+00:00at /app/node_modules/jsonwebtoken/sign.js:52:15 2023-01-08 07:12:03.673268+00:00at Array.forEach () 2023-01-08 07:12:03.673281+00:00at validate (/app/node_modules/jsonwebtoken/sign.js:43:6) 2023-01-08 07:12:03.673291+00:00at validatePayload (/app/node_modules/jsonwebtoken/sign.js:62:10) 2023-01-08 07:12:03.673306+00:00at Object.module.exports [as sign] (/app/node_modules/jsonwebtoken/sign.js:114:7) 2023-01-08 07:12:03.673325+00:00at exports.generateJWT (/app/authentication/auth.js:229:19) 2023-01-08 07:12:03.673337+00:00at Layer.handle [as handle_request] (/app/node_modules/express/lib/router/layer.js:95:5) 2023-01-08 07:12:03.673348+00:00at next (/app/node_modules/express/lib/router/route.js:137:13) 2023-01-08 07:12:03.673367+00:00at complete (/app/node_modules/passport/lib/middleware/authenticate.js:268:13) 2023-01-08 07:12:03.673379+00:00at /app/node_modules/passport/lib/middleware/authenticate.js:275:15 2023-01-08 07:12:03.673390+00:00at pass (/app/node_modules/passport/lib/authenticator.js:431:14) 2023-01-08 07:12:03.673401+00:00at Authenticator.transformAuthInfo (/app/node_modules/passport/lib/authenticator.js:453:5) 2023-01-08 07:12:03.673422+00:00at /app/node_modules/passport/lib/middleware/authenticate.js:272:22 2023-01-08 07:12:03.673433+00:00at /app/node_modules/passport/lib/http/request.js:52:7 2023-01-08 07:12:03.673444+00:00at /app/node_modules/passport/lib/sessionmanager.js:26:5 2023-01-08 07:12:03.673461+00:00at pass (/app/node_modules/passport/lib/authenticator.js:277:43)

Looking at the error.log file - it doesn't log an error unless I use a username it doesn't know, so it seems to be checking the username, just not getting past something after that.

I used all default settings for the config via the TrueNAS docker - I'm not a docker wizard so I'm not sure where to go next, or if the problem is something caused by TrueNAS...

Thanks :)

rkolja76 commented 1 year ago

Same issue here on Docker.

g2bb commented 1 year ago

I'm having the same issue. Just updated to the latest TrueChart release earlier same issue

g2bb commented 1 year ago

Any update on this issue? I've been messing with it again today, with no luck. I recreated the container from scratch enabling multi-user mode from the start. It prompted setting an admin password but when I went to log in with that password using the 'admin' username it still came up with 'Login Failed - Unknown Error'

Tzahi12345 commented 1 year ago

@g2bb Can you post your logs, default.json settings (in appdata), and your docker-compose.yml?

From @duk242 the issue seems to be the following:

2023-01-08 07:12:03.673164+00:00Error: "exp" should be a number of seconds

That comes from the following lines of code in backend/authentication/auth.js:

https://github.com/Tzahi12345/YoutubeDL-Material/blob/da17d903e1024137e52aa259b955efd697a21dc9/backend/authentication/auth.js#L224-L231

One of a couple things is happening. Either the jwt_expiration setting is not properly set or the initialization code where JWT_EXPIRATION is set is not executing for whatever reason, but I'd need more info to see what's really happening.

g2bb commented 1 year ago

I spun a fresh install up on my TrueNAS server via the TrueCharts repo the ONLY setting I changed was to enable Multi-User mode. Unfortunately, because I'm using an existing app I can't send a docker-compose.yml, but I can send a screenshot. Below you'll find a link to my logs on Pastebin. I'm not sure if those are what you're looking for but that is what I have access to via TrueNAS

YoutubeDL-Material Logs: https://pastebin.com/1eYNL4ZE DB-Wait Logs: https://pastebin.com/US54fTYe MongoDB Logs: https://pastebin.com/isy6r58g

Default.JSON: https://pastebin.com/iyWGnnej

Tzahi12345 commented 1 year ago

Looks like you have the same issue as @duk242

Can you try one thing: in your default.json, can you remove the quotes from the value of jwt_expiration? i.e. do this:

"jwt_expiration": 86400,
Tzahi12345 commented 1 year ago

Just confirmed this was the issue, will be closed when I merge #809 shortly!

g2bb commented 1 year ago

Unfortunately that still didn't work for me. I even tried recreating it, removing the quotes, restarting and THEN creating the account and still no luck. Same "Unknown" Error

Tzahi12345 commented 1 year ago

@g2bb can you pull the latest nightly and see if that works?

g2bb commented 1 year ago

Apologies for the delay I've been busy lately. I took some time tonight to give this a go and I was able to get it working on my local network with the absolute base configuration, but there is no way for me to set up a reverse proxy, or to pick where on my server the files are being stored. Everything lives in another container which severely limits me.

At this point, I suspect it's a TrueCharts issue and not a YTDL issue. I'm going to submit a support ticket with TrueCharts and I will keep you apprised.