|
@@ -4,6 +4,7 @@ import { ConfigService } from '@nestjs/config';
|
|
|
import { JwtService } from '@nestjs/jwt';
|
|
|
import { InjectModel } from '@nestjs/mongoose';
|
|
|
import { Model } from 'mongoose';
|
|
|
+import { v4 as uuid } from 'uuid';
|
|
|
import { catchError, lastValueFrom, map } from 'rxjs';
|
|
|
|
|
|
import { User, UserDocument } from './models/user.model';
|
|
@@ -76,6 +77,7 @@ export class AuthService {
|
|
|
this.userModel.create({
|
|
|
vatsimId: userdata.cid,
|
|
|
fullName,
|
|
|
+ radarScopeKey: uuid(),
|
|
|
vatsimToken: token,
|
|
|
vatsimRefreshToken: refreshToken,
|
|
|
});
|
|
@@ -110,4 +112,15 @@ export class AuthService {
|
|
|
return user;
|
|
|
});
|
|
|
}
|
|
|
+
|
|
|
+ async resetRadarScopeKey(token: string): Promise<void> {
|
|
|
+ const payload = this.jwtService.verify(token, {
|
|
|
+ secret: this.config.get<string>('server.jwt-secret'),
|
|
|
+ });
|
|
|
+
|
|
|
+ await this.userModel.findOneAndUpdate(
|
|
|
+ { vatsimId: payload.vatsimId },
|
|
|
+ { radarScopeKey: uuid() },
|
|
|
+ );
|
|
|
+ }
|
|
|
}
|