mirror of
https://github.com/AmruthPillai/Reactive-Resume.git
synced 2025-11-17 02:01:29 +10:00
feat(all): upgrade to v3.4.0
This commit is contained in:
@ -21,8 +21,8 @@ export class AuthController {
|
||||
}
|
||||
|
||||
@Post('google')
|
||||
async loginWithGoogle(@Body('accessToken') googleAccessToken: string) {
|
||||
const user = await this.authService.authenticateWithGoogle(googleAccessToken);
|
||||
async loginWithGoogle(@Body('credential') credential: string) {
|
||||
const user = await this.authService.authenticateWithGoogle(credential);
|
||||
const accessToken = this.authService.getAccessToken(user.id);
|
||||
|
||||
return { user, accessToken };
|
||||
|
||||
@ -4,7 +4,7 @@ import { JwtService } from '@nestjs/jwt';
|
||||
import { SchedulerRegistry } from '@nestjs/schedule';
|
||||
import bcrypt from 'bcrypt';
|
||||
import { randomInt } from 'crypto';
|
||||
import { google } from 'googleapis';
|
||||
import { OAuth2Client } from 'google-auth-library';
|
||||
|
||||
import { PostgresErrorCode } from '@/database/errorCodes.enum';
|
||||
import { CreateGoogleUserDto } from '@/users/dto/create-google-user.dto';
|
||||
@ -107,17 +107,16 @@ export class AuthService {
|
||||
return this.usersService.findById(payload.id);
|
||||
}
|
||||
|
||||
async authenticateWithGoogle(googleAccessToken: string) {
|
||||
async authenticateWithGoogle(credential: string) {
|
||||
const clientID = this.configService.get<string>('google.clientID');
|
||||
const clientSecret = this.configService.get<string>('google.clientSecret');
|
||||
|
||||
const OAuthClient = new google.auth.OAuth2(clientID, clientSecret);
|
||||
OAuthClient.setCredentials({ access_token: googleAccessToken });
|
||||
|
||||
const { email } = await OAuthClient.getTokenInfo(googleAccessToken);
|
||||
const OAuthClient = new OAuth2Client(clientID, clientSecret);
|
||||
const client = await OAuthClient.verifyIdToken({ idToken: credential });
|
||||
const userPayload = client.getPayload();
|
||||
|
||||
try {
|
||||
const user = await this.usersService.findByEmail(email);
|
||||
const user = await this.usersService.findByEmail(userPayload.email);
|
||||
|
||||
return user;
|
||||
} catch (error: any) {
|
||||
@ -125,14 +124,12 @@ export class AuthService {
|
||||
throw new HttpException(error, HttpStatus.BAD_GATEWAY);
|
||||
}
|
||||
|
||||
const UserInfoClient = google.oauth2('v2').userinfo;
|
||||
const { data } = await UserInfoClient.get({ auth: OAuthClient });
|
||||
const username = data.email.split('@')[0];
|
||||
const username = userPayload.email.split('@')[0];
|
||||
|
||||
const createUserDto: CreateGoogleUserDto = {
|
||||
name: `${data.given_name} ${data.family_name}`,
|
||||
name: `${userPayload.given_name} ${userPayload.family_name}`,
|
||||
username,
|
||||
email: data.email,
|
||||
email: userPayload.email,
|
||||
provider: 'google',
|
||||
};
|
||||
|
||||
|
||||
22037
server/src/fonts/assets/cachedResponse.json
Normal file
22037
server/src/fonts/assets/cachedResponse.json
Normal file
File diff suppressed because it is too large
Load Diff
@ -5,6 +5,8 @@ import { Font } from '@reactive-resume/schema';
|
||||
import { get } from 'lodash';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
|
||||
import cachedResponse from './assets/cachedResponse.json';
|
||||
|
||||
@Injectable()
|
||||
export class FontsService {
|
||||
constructor(private configService: ConfigService, private httpService: HttpService) {}
|
||||
@ -13,8 +15,14 @@ export class FontsService {
|
||||
const apiKey = this.configService.get<string>('google.apiKey');
|
||||
const url = 'https://www.googleapis.com/webfonts/v1/webfonts?key=' + apiKey;
|
||||
|
||||
const response = await firstValueFrom(this.httpService.get(url));
|
||||
const data = get(response.data, 'items', []);
|
||||
let data = [];
|
||||
|
||||
if (apiKey) {
|
||||
const response = await firstValueFrom(this.httpService.get(url));
|
||||
data = get(response.data, 'items', []);
|
||||
} else {
|
||||
data = cachedResponse;
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@ -10,6 +10,7 @@ const defaultState: Partial<Resume> = {
|
||||
basics: {
|
||||
email: '',
|
||||
headline: '',
|
||||
birthdate: '',
|
||||
photo: {
|
||||
url: '',
|
||||
visible: true,
|
||||
|
||||
@ -5,6 +5,7 @@ const sampleData: Partial<Resume> = {
|
||||
name: 'Alexis Jones',
|
||||
email: 'alexis.jones@gmail.com',
|
||||
phone: '+1 800 1200 3820',
|
||||
birthdate: '1995-08-06T00:00:00.000Z',
|
||||
photo: {
|
||||
url: `/images/sample-photo.jpg`,
|
||||
filters: {
|
||||
|
||||
@ -35,6 +35,8 @@ export class ResumeController {
|
||||
@UseGuards(JwtAuthGuard)
|
||||
@Get()
|
||||
async findAllByUser(@User('id') userId: number) {
|
||||
console.log('findAllByUser', userId);
|
||||
|
||||
return this.resumeService.findAllByUser(userId);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user