request в таком сценарии??
                  
                  
                  export class GoogleLoginStrategy extends PassportStrategy(GoogleStrategy, 'google-token') {
                  
                  
                    constructor(private readonly userSessionService: UserSessionService, private readonly configService: ConfigService) {
                  
                  
                      // eslint-disable-next-line @typescript-eslint/no-explicit-any
                  
                  
                      super(configService.googleStrategyConfig,
                  
                  
                        async (accessToken: string, refreshToken: string, profile: any, done: Function) => {
                  
                  
                          try {
                  
                  
                            if (!profile._json.verified_email) {
                  
                  
                              done(new Error('email is not verified'), null);
                  
                  
                            }
                  
                  
                            const socialProfile: SocialProfile = {
                  
                  
                              email: profile._json.email,
                  
                  
                              id: profile.id,
                  
                  
                              fullName: profile.name?.givenName + ' ' + profile.name?.familyName,
                  
                  
                              social: Social.GOOGLE,
                  
                  
                            };
                  
                  
                  
                  
                  
                            const user = await this.userSessionService.signupBySocial(socialProfile);
                  
                  
                            done(null, user);
                  
                  
                          } catch (err) {
                  
                  
                            done(err, null);
                  
                  
                          }
                  
                  
                  
                  
                  
                        });
                  
                  
                    }
                  
                  
                  }
                  
                  
                
Юзера получишь хочешь?
Суть в том что когда приходит новый пользователь, мне нужно получить новое имя уникальное имя которое он должен вписать в форму, и я не понимаю каким образом его отловить можно
Покажи де юзаешь авторизацию, и обрабатываешь форму юзера
Да собственно вот. Есть контроллер с декораторами и в проваейдере у меня прописана стратегия по гуглу @ApiOk({ summary: 'Вход через google' }, { type: UserPasswordLoginPayloadDto }) @UseGuards(JwtGoogleAuthGuard) @UseInterceptors(GoogleAuthInterceptor) @Get('signupGoogle') async signupGoogle(@UserTransport() user: UserDti): Promise<UserPasswordLoginPayloadDto> { if (user.deleted !== DeletedStatuses.NOT_DELETED) { throw new UserDeletedException(); } const token = await this.userSessionService.createToken(user); return new UserPasswordLoginPayloadDto(user, token); } export class GoogleLoginStrategy extends PassportStrategy(GoogleStrategy, 'google-token') { constructor(private readonly userSessionService: UserSessionService, private readonly configService: ConfigService) { // eslint-disable-next-line @typescript-eslint/no-explicit-any super(configService.googleStrategyConfig, (req: Request, res: Response) => { async (accessToken: string, refreshToken: string, profile: any, done: Function) => { try { process.nextTick(() => { console.log('======req', req, '======req'); }) if (!profile._json.verified_email) { done(new Error('email is not verified'), null); } const socialProfile: SocialProfile = { email: profile._json.email, id: profile.id, fullName: profile.name?.givenName + ' ' + profile.name?.familyName, social: Social.GOOGLE, }; const user = await this.userSessionService.signupBySocial(socialProfile); done(null, user); } catch (err) { done(err, null); } } }); } } И тк старый код просто вписывает uuid вместо имени юзера, мне нужно его изменить на обычное имя. И у меня появилась идея что можно это имя с фронта запихать в url и вмомент проверки гугла получать это имя и вписывать в бд. Клиент не я пишу
ну функцию (req: Request, res: Response) => { не обращай внимание, это я эксперементирую)
Обсуждают сегодня