feat(users): add editable usernames (#715)

This commit is contained in:
Jakob Ankarhem
2021-01-27 00:09:42 +01:00
committed by GitHub
parent 82ac76b054
commit 20ca3f2f5f
19 changed files with 284 additions and 175 deletions

View File

@@ -6,6 +6,7 @@ import {
UpdateDateColumn,
OneToMany,
RelationCount,
AfterLoad,
} from 'typeorm';
import { Permission, hasPermission } from '../lib/permissions';
import { MediaRequest } from './MediaRequest';
@@ -25,14 +26,19 @@ export class User {
static readonly filteredFields: string[] = ['plexToken', 'password'];
public displayName: string;
@PrimaryGeneratedColumn()
public id: number;
@Column({ unique: true })
public email: string;
@Column()
public username: string;
@Column({ nullable: true })
public plexUsername: string;
@Column({ nullable: true })
public username?: string;
@Column({ nullable: true, select: false })
public password?: string;
@@ -125,4 +131,9 @@ export class User {
});
}
}
@AfterLoad()
public setDisplayName(): void {
this.displayName = this.username || this.plexUsername;
}
}