fix(plex): do not fail to import Plex users when Plex Home has managed users (#1699)

* fix(plex): do not fail to import Plex users when Plex Home has managed users

* fix: default display name to email when user has no username

also, do not set username or plexUsername when it is the same as the user's email address

* fix(ui): user display name placeholder should reflect fallback logic if username is not set

* fix(ui): hide email addresses of other users if logged-in user does not have Manage Users permission

* fix: always set Plex username even if same as user's email

* fix: remove unnecessary permission check

* fix: transform email addresses to lowercase
This commit is contained in:
TheCatLady
2021-05-30 19:38:52 -04:00
committed by GitHub
parent 6603dffe95
commit 310cdb36df
7 changed files with 68 additions and 61 deletions

View File

@@ -48,11 +48,17 @@ export class User {
@PrimaryGeneratedColumn()
public id: number;
@Column({ unique: true })
@Column({
unique: true,
transformer: {
from: (value: string): string => value.toLowerCase(),
to: (value: string): string => value.toLowerCase(),
},
})
public email: string;
@Column({ nullable: true })
public plexUsername: string;
public plexUsername?: string;
@Column({ nullable: true })
public username?: string;
@@ -220,7 +226,7 @@ export class User {
@AfterLoad()
public setDisplayName(): void {
this.displayName = this.username || this.plexUsername;
this.displayName = this.username || this.plexUsername || this.email;
}
public async getQuota(): Promise<QuotaResponse> {