Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Plex user accept an invite, invite used but expire date is NULL #165

Closed
enrico1203 opened this issue Jun 22, 2023 · 13 comments
Closed

Comments

@enrico1203
Copy link

enrico1203 commented Jun 22, 2023

Describe the bug
Sometimes a plex user claim an invite. the invite is correctly marked as used and the mail is correct and gain the access to the libraries. But on the user panel there is no expire date. If i open the sqlite database to see the data this user on "users" table look like this:
167 None name mail@gmail.com None
token,code are none and expire is null.
The invite look like this:
50 YKAIOZ 1 2023-06-21 11:45 2023-06-21 11:43 mail@gmail.com 2023-06-22 11:43:56 0 2 Library 1 0

I can't reproduce this bug all the time. sometimes it works right away and in the users table it looks like this:
165 vWYs9kEy2mVDgcW***** user mail@hotmail.it Q2BYPF 2024-06-20 11:12:18.450443

Additional context
Add any other context about the problem here.
1
2

I'm using the latest docker image

@mtthidoteu
Copy link
Contributor

mtthidoteu commented Jun 22, 2023 via email

@enrico1203
Copy link
Author

Another example: This invite with the duration of 186 days
1
on the user panel i see this:
2
where I drew the question mark there should be the date like in all the others. when the current date passes those dates the user is taken off plex. but in this case it is not there and therefore it remains forever

@DjBuRnOuT
Copy link

DjBuRnOuT commented Jul 24, 2023

I've got the same problem, not sure what would cause this. Here's the invitations table:
image

and here's the users table:
image

You can see that the invitation code gets used but it doesn't reflect in the users table.

I'm also using the latest version of the docker image as of today

@realashleybailey
Copy link
Contributor

realashleybailey commented Jul 25, 2023 via email

@DjBuRnOuT
Copy link

DjBuRnOuT commented Jul 25, 2023

Is this issue occurring with the V3-alpha or are you using the default provided version of Wizard

On 24 Jul 2023, at 10:05 pm, DjBuRnOuT @.***> wrote: I've got the same problem, not sure what would cause this. Here's the invitations table: https://user-images.githubusercontent.com/1522047/255718109-b0e1693b-f176-4ce1-b8f0-11bf0604b1fb.png and here's the users table: https://user-images.githubusercontent.com/1522047/255718347-73ae8919-5fff-4d2c-a206-e52b1b4da8d7.png You can see that the invitation code gets used but it doesn't reflect in the users table. — Reply to this email directly, view it on GitHub <#165 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD65Q3FV4CFCKTEQYZDJN7LXR3PTFANCNFSM6AAAAAAZP2WOJ4. You are receiving this because you are subscribed to this thread.

it's happening in the latest "stable" version available in the master branch of the default repo: https://github.com/Wizarrrr/wizarr

Specifically this image in the docker compose file: image: ghcr.io/wizarrrr/wizarr

@realashleybailey
Copy link
Contributor

realashleybailey commented Jul 26, 2023

I think like @mtthidoteu mentioned, theres two forms of "expiration", theres what Wizarr calls expiration, and that is the duration of validity for an invite, this is not ignored if unlimited is set to true, and theres duration, this is the length of validity for any created accounts using that invite, after this duration the account is removed from the media server and the user no longer maintains access.

wizarrrrrrr

@DjBuRnOuT
Copy link

I think like @mtthidoteu mentioned, theres two forms of "expiration", theres what Wizarr calls expiration, and that is the duration of validity for an invite, this is not ignored if unlimited is set to true, and theres duration, this is the length of validity for any created accounts using that invite, after this duration the account is removed from the media server and the user no longer maintains access.

wizarrrrrrr

No it's not the case, I didn't mismatched the two forms of expiration and it's why I replied to this very ticket because it looks like a real bug, I made sure to not make any mistakes before posting.

I've tried to look up at the logs but except for some Plex API limits being reached I don't see anything else. It's really a random bug that I cannot even reproduce because some users are getting expected results while some don't. I have a pretty big plex server so I did remove everyone to re-invite them back using wizarr and it doesn't look like there's a pattern I can identify for the moment.

Here's more proof directly from wizarr's interface (sorry for the unusually large and wide screenshot)
image

As you can see with the comments, annotations and relations that I drew. Invitations are getting used and matched to the correct email but in the users table in the database, it misses the code used by that user and the date it's supposed to expire. (hence why I posted the values from the databse using DB Browser for SQLite some posts above)

I'm new to Python, I wish I could do better to help you out (or fix it myself) but I can only provide useful informations (maybe?) for now.

@realashleybailey
Copy link
Contributor

realashleybailey commented Jul 26, 2023

@DjBuRnOuT Don't worry I believe you, often times we get bug reports that turn out to be just user error so its great to make sure everyone is 100% on the same page before any in depth debugging, if this bug is occurring in a somewhat sporadic nature I would most likely pin point it to the way Wizarr currently stores these values.

https://github.com/Wizarrrr/wizarr/blob/master/app/admin.py#L76

current_date = date.today()
            expires_options = {
                "day": (current_date + timedelta(days=1)),
                "week": (current_date + timedelta(weeks=1)),
                "month": (current_date + timedelta(days=30)), # Approximation for 1 month
                "6months": (current_date + timedelta(days=30*6)), # Approximation for 6 months
                "year": (current_date + timedelta(days=365)),   # Approximation for 1 year     
                "never": None
            }
            expires = expires_options.get(request.form.get("expires"))
            unlimited = 1 if request.form.get("unlimited") else 0
            plex_home = 1 if request.form.get("plex_home") else 0
            allowsync = 1 if request.form.get("allowsync") else 0
            duration = request.form.get("duration")
            specific_libraries = None
            library_count = int(request.form.get("library_count", 0))
            if library_count > 0:
                specific_libraries = ', '.join(filter(None, [
                    request.form.get("library_" + str(library))
                    for library in range(library_count + 1)
                ]))

            # Create invitation
            Invitations.create(
                code=code,
                used=False,
                created=datetime.datetime.now().strftime("%Y-%m-%d %H:%M"),
                expires=expires.strftime(
                    "%Y-%m-%d %H:%M:%S") if expires else None,
                unlimited=unlimited,
                plex_home=plex_home,
                duration=duration,
                specific_libraries=specific_libraries,
                plex_allow_sync=allowsync
            )

I have a feeling that expires = expires_options.get(request.form.get("expires")) might not be correctly parsing the expires correctly.

Because this issue is difficult to replicate is it possible that you could provide me with a copy of your database.db so that I can inspect the formatting of the expire values.

You can use this link to upload your file securely, https://cloud.gitcloud.org/url/zuddpigp6gfjqiiy, [Privacy Policy Stuff] your file will be deleted immediately once I have completed my debugging. Your personal data will not be shared with anyone whether that be public or on the Wizarr team without your express approval beforehand.

@DjBuRnOuT
Copy link

Doesn't look like that link works for me, it sends me back to the issues page of the repo. Is that alright if I send it to you using the email listed on your profile?

I mean it's not top secret stuff but I want to avoid posting the emails of my friends at the very least otherwise I would've just attached it to my post lol

@realashleybailey
Copy link
Contributor

Yes feel free to email it over to me, if your outside of europe that maybe why the link does not work for your apologies for that.

@DjBuRnOuT
Copy link

That's a probability, i'm from Canada. I've just sent you an email with my current database attached. Thanks for your time!

@realashleybailey
Copy link
Contributor

@DjBuRnOuT Okay I have looked at the database, one thing that strikes me as odd is that the only users that don't have expire dates also don't have Plex tokens, or invite codes associated with them. My first thoughts on analysis is weather these users were automatically imported from Plex to Wizarr, instead of the accounts being created through the Wizarr signup process, I am currently working on V3 and so it will give me time to closely go over the code for the Plex signup process, if this is a bug then I am hopeful to catch it before that release. Ill keep this thread open until I have resolved the issue and will get back to you.

@DjBuRnOuT
Copy link

Just sent you another mail with my refreshed database since i've got two new users that registered in the past 24 hours. As you'll be able to see, one had it's expiration date correctly as expected and the other one didn't. Still no clue as to why it happens.

One thing to keep in mind is that I have a managed account for my girlfriend which didn't went through Wizarr and two of the first users that were added manually to Plex (User ID 1 to 3 to be exact), so you can overlook those, they are not bugged. All the other users got registered through Wizarr.

I will keep trying to find out more and provide the info to you. Does the "token" really necessary? I ask this because I wanted to know if I can add the invitation code and the expiration timestamp manually or it needs the token for it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants