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

feat: ✨Ability to specify whether a user displays on login page #397

Merged
merged 5 commits into from
Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# CREATED ON VERSION: V4.0.0
# MIGRATION: 2024-04-30_16-44-17
# CREATED: Tue Apr 30 2024
#

from peewee import *
from playhouse.migrate import *

from app import db

# Do not change the name of this file,
# migrations are run in order of their filenames date and time

def run():
# Use migrator to perform actions on the database
migrator = SqliteMigrator(db)

# Add new Column to users table, its a boolean field with a default value of True
with db.transaction():
# Check if the column exists
cursor = db.cursor()
cursor.execute("PRAGMA table_info(invitations);")
columns = cursor.fetchall()
column_names = [column[1] for column in columns]

if "hide_user" not in column_names:
db.execute_sql("ALTER TABLE invitations ADD COLUMN hide_user INTEGER SET DEFAULT 1")
else:
print("Column hide_user already exists")

print("Migration 2024-04-30_16-44-17 complete")
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ class Invitations(BaseModel):
plex_home = BooleanField(null=True, default=None)
sessions = CharField(null=True, default=None)
live_tv = BooleanField(null=True, default=None)
hide_user = BooleanField(null=True, default=True)
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class InvitationsModel(Model):
plex_home = BooleanType(required=False, default=False)
used_at = DateTimeType(required=False, default=None, convert_tz=True)
created = DateTimeType(required=False, default=datetime.utcnow(), convert_tz=True)
hide_user = BooleanType(required=False, default=True)


# ANCHOR - Validate Code
Expand Down
4 changes: 4 additions & 0 deletions apps/wizarr-backend/wizarr_backend/helpers/emby.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ def invite_emby_user(username: str, password: str, code: str, server_api_key: Op
else:
new_policy["EnableLiveTvAccess"] = False

# Set the hidden user status
if invitation.hide_user is not None and invitation.hide_user == False:
new_policy["IsHiddenRemotely"] = False

# Get users default policy
old_policy = user_response["Policy"]

Expand Down
4 changes: 4 additions & 0 deletions apps/wizarr-backend/wizarr_backend/helpers/jellyfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,10 @@ def invite_jellyfin_user(username: str, password: str, code: str, server_api_key
else:
new_policy["EnableLiveTvAccess"] = False

# Set the hidden user status
if invitation.hide_user is not None and invitation.hide_user == False:
new_policy["IsHidden"] = False

# Get users default policy
old_policy = user_response["Policy"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export default defineComponent({
inviteCode: "",
expiration: 1440 as number | null | "custom",
customExpiration: "" as string,
checkboxes: ["live_tv"] as string[], // Add the checkboxes you want to be checked by default
checkboxes: ["live_tv", "hide_user"] as string[],// Add the checkboxes you want to be checked by default
duration: "unlimited" as number | "unlimited" | "custom",
customDuration: "" as string,
libraries: [] as string[],
Expand Down Expand Up @@ -184,6 +184,10 @@ export default defineComponent({
label: "Access to Live TV",
value: "live_tv",
},
hide_user: {
label: "Hide User from the Login Page",
value: "hide_user",
},
},
emby: {
unlimited: {
Expand All @@ -194,6 +198,10 @@ export default defineComponent({
label: "Access to Live TV",
value: "live_tv",
},
hide_user: {
label: "Hide User from the Login Page",
value: "hide_user",
},
},
plex: {
unlimited: {
Expand Down Expand Up @@ -265,6 +273,7 @@ export default defineComponent({
const plex_home = invitationData.checkboxes.includes("plex_home");
const plex_allow_sync = invitationData.checkboxes.includes("plex_allow_sync");
const live_tv = invitationData.checkboxes.includes("live_tv");
const hide_user = invitationData.checkboxes.includes("hide_user");
const sessions = invitationData.sessions;
const duration = invitationData.duration == "custom" ? this.$filter("toMinutes", invitationData.customDuration) : invitationData.duration == "unlimited" ? null : invitationData.duration;
const libraries = invitationData.libraries;
Expand All @@ -276,6 +285,7 @@ export default defineComponent({
plex_home: plex_home,
plex_allow_sync: plex_allow_sync,
live_tv: live_tv,
hide_user: hide_user,
sessions: sessions,
duration: duration,
specific_libraries: JSON.stringify(libraries),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ export default defineComponent({
label: "Access to Live TV",
value: this.invitation.live_tv,
},
hide_user: {
label: "Hide User from the Login Page",
value: this.invitation.hide_user,
},
},
emby: {
unlimited: {
Expand All @@ -116,6 +120,10 @@ export default defineComponent({
label: "Access to Live TV",
value: this.invitation.live_tv,
},
hide_user: {
label: "Hide User from the Login Page",
value: this.invitation.hide_user,
},
},
plex: {
unlimited: {
Expand Down
1 change: 1 addition & 0 deletions apps/wizarr-frontend/src/types/api/invitations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface Invitation {
plex_allow_sync: boolean;
plex_home: boolean;
live_tv: boolean;
hide_user: boolean;
sessions: number;
specific_libraries: string;
unlimited: boolean;
Expand Down