introduce a function to receive user data
This commit is contained in:
@@ -6,7 +6,7 @@ import { InjectModel } from '@nestjs/mongoose';
|
||||
import { Model } from 'mongoose';
|
||||
import { catchError, lastValueFrom, map } from 'rxjs';
|
||||
|
||||
import { UserDocument } from './models/user.model';
|
||||
import { User, UserDocument } from './models/user.model';
|
||||
|
||||
@Injectable()
|
||||
export class AuthService {
|
||||
@@ -66,7 +66,7 @@ export class AuthService {
|
||||
);
|
||||
|
||||
if (userdata.oauth.token_valid) {
|
||||
let fullName = 'Private';
|
||||
let fullName = '';
|
||||
if (userdata.personal !== undefined) {
|
||||
fullName = userdata.personal.name_full;
|
||||
}
|
||||
@@ -97,4 +97,17 @@ export class AuthService {
|
||||
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async user(token: string): Promise<User> {
|
||||
const payload = this.jwtService.verify(token, {
|
||||
secret: this.config.get<string>('server.jwt-secret'),
|
||||
});
|
||||
|
||||
return this.userModel
|
||||
.findOne({ vatsimId: payload.vatsimId })
|
||||
.then((user) => {
|
||||
if (!user) return undefined;
|
||||
return user;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user