add functions to login the radar scope

This commit is contained in:
Sven Czarnian
2022-11-04 21:47:34 +01:00
parent 912a8e7509
commit 822b39f4fd
3 changed files with 61 additions and 1 deletions

View File

@@ -113,6 +113,15 @@ export class AuthService {
});
}
async loginRadarScope(vatsimId: string, key: string): Promise<string> {
return this.userModel.findOne({ vatsimId }).then((user) => {
if (!user || user.radarScopeKey !== key) return undefined;
const payload = { vatsimId: vatsimId, sub: key };
return this.jwtService.sign(payload);
});
}
async resetRadarScopeKey(token: string): Promise<void> {
const payload = this.jwtService.verify(token, {
secret: this.config.get<string>('server.jwt-secret'),