feat: user avatars from plex (#53)

This commit is contained in:
sct
2020-09-06 19:30:16 +09:00
committed by GitHub
parent 190a8831c7
commit e6349c13a0
6 changed files with 19 additions and 6 deletions

View File

@@ -27,6 +27,9 @@ export class User {
@Column({ type: 'integer', default: 0 })
public permissions = 0;
@Column()
public avatar: string;
@CreateDateColumn()
public createdAt: Date;

View File

@@ -23,6 +23,8 @@ components:
permissions:
type: number
example: 0
avatar:
type: string
createdAt:
type: string
example: '2020-09-02T05:02:23.000Z'

View File

@@ -46,6 +46,9 @@ authRoutes.post('/login', async (req, res) => {
user.plexToken = body.authToken;
await userRepository.save(user);
}
// Update the users avatar with their plex thumbnail (incase it changed)
user.avatar = account.thumb;
} else {
// Here we check if it's the first user. If it is, we create the user with no check
// and give them admin permissions
@@ -56,6 +59,7 @@ authRoutes.post('/login', async (req, res) => {
email: account.email,
plexToken: account.authToken,
permissions: Permission.ADMIN,
avatar: account.thumb,
});
await userRepository.save(user);
}