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

Basic Multi-User Setup #217

Draft
wants to merge 5 commits into
base: dev
Choose a base branch
from
Draft

Basic Multi-User Setup #217

wants to merge 5 commits into from

Conversation

jacovanc
Copy link

This is not ready to merge. I haven't quite finished/tested properly yet and will get to the rest later this week. But I thought I'd get this pull request up so you can take a look and let me know if you want anything done differently.

Main things are:

Added an endpoint to check if the current user is an admin.

This might have been better done as part of the general 'get user data' endpoint and then we could just check the is_admin property specifically whenever needed. However I see there's no global state and didn't want to pass data between components too much. This endpoint is currently only used on the admin settings page (in case the user navigates there manually it will just show an error).

Jellyfin default enabled setting

Currently the jellyfin 'enabled' toggle defaults to false. This may be annoying for users that are currently using Jellyfin (they'd probably have to go re-enable it). Not sure if you have any specific way you want to solve that? Of course we could just default it to true, but seems odd to be enabled when they haven't added their api key etc.

Middleware for admin sections

I've added a middleware to protect the admin sections. There are various other endpoints that should be moved into that middleware section - but I know I'd miss plenty so figured perhaps better if someone more familiar with all the routes did this.

Lastly, I have no idea how the anki stuff works (haven't looked at all yet) - I've not used this feature personally. Let me know if there's anything I should know for that (or if someone else wants to take over that part)

@jacovanc jacovanc marked this pull request as draft April 23, 2024 15:07
@jacovanc
Copy link
Author

References Issue #24

Copy link
Owner

@simjanos-dev simjanos-dev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basic Multi-User Setup commit

Marked an error (I think).

Add Jellyfin "Enable" toggle

Marked a missing json_decode.

get to the rest later this week

Please take as much time as you need.

This may be annoying for users that are currently using Jellyfin (they'd probably have to go re-enable it). Not sure if you have any specific way you want to solve that?

I'll just leave a note in the update notes.

Middleware for admin sections

I'll check and move every route to the admin group when the PR is ready otherwise.

Lastly, I have no idea how the anki stuff works (haven't looked at all yet) - I've not used this feature personally. Let me know if there's anything I should know for that (or if someone else wants to take over that part)

It basically just sends AnkiConnect plugin http requests to add review cards to it. Anki is a review software desktop application.

It might be a bit difficult to understand if you are not familiar with Anki. If we release multi user feature without rewriting this part everything would work, except if a user clicks on the send to Anki button, it would get an error. It could cause some confusion.

I could rewrite it in a few hours, but honestly I'm feeling a bit burned out, I want to focus on other things for a while.

Can I ask how bad or good my code is to work on? I rarely worked with other people before, so I never got any feedback on it.

app/Http/Controllers/MediaPlayerController.php Outdated Show resolved Hide resolved
resources/js/components/Admin/AdminUserSettings.vue Outdated Show resolved Hide resolved
@jacovanc
Copy link
Author

Great thanks, made those changes.

Code is all clear and easy to work on! Main thing I noticed though is that all api routes are in the web routes file. Not an issue but when creating middleware that returns a response we have to be careful whether it's a JSON or HTML response based on which endpoints it's used on. Splitting up the routes makes it easier to reason about that.

I have used Anki before - I will go ahead doing the Anki stuff if there's no rush, after I set it up on my live deployment which I should probably do anyway :)

@simjanos-dev
Copy link
Owner

Main thing I noticed though is that all api routes are in the web routes file

Currently refactoring my controllers #103. In the files that are already complete, they (should) all return JSON responses, except the Home controller's index which is the actual page.

Anki

I reread my first description, I don't think I explained it well. The problem is that currently when a user sends a card to Anki, the browser sends a request to the server, and the server sends it to Anki. But if there are multiple users, it doesn't make sense, so instead their own browser should send the Anki requests to their own Anki program. But this way the logic must also move from the server to the client.

Actually, just realized that there might be a problem. If we make this change, the client will have to have access to the Anki program's network. So if someone hosts linguacafe, they won't be able to send cards to Anki remotely through the linguacafe server, the client itself will have to have acces to Anki's network.

I think this is an acceptable compromise, but not sure.

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

Successfully merging this pull request may close these issues.

None yet

2 participants