Skip to content

Commit

Permalink
push incendie
Browse files Browse the repository at this point in the history
  • Loading branch information
B-ki committed Oct 30, 2023
1 parent 9ca897e commit 5f4ccea
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 7 deletions.
2 changes: 0 additions & 2 deletions api/src/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ export class AuthController {
@Get('42/callback')
@UseGuards(FortyTwoAuthGuard)
async auth42callback(@Req() req: any): Promise<{ token: string; login: string }> {
const logger = new Logger();
logger.debug(req.user);
return {
token: await this.authService.login(req.user),
login: req.user.login,
Expand Down
2 changes: 1 addition & 1 deletion api/src/modules/auth/auth.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export class JwtPayload {
login: string;
}

export class CreateUserDto {
export interface CreateUserDto {
//@IsNotEmpty()
login: string;

Expand Down
2 changes: 0 additions & 2 deletions api/src/modules/auth/guards/42.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { TokenError } from 'passport-oauth2';
@Injectable()
export class FortyTwoAuthGuard extends AuthGuard('42') {
override handleRequest<TUser = any>(err: any, user: any): TUser {
const logger = new Logger();
logger.debug(`user = ${user}`);
if (err || !user) {
if (err instanceof TokenError) {
throw new UnauthorizedException(err.message);
Expand Down
2 changes: 0 additions & 2 deletions api/src/modules/auth/strategies/42.strategy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ export class FortyTwoStrategy extends PassportStrategy(Strategy, '42') {
}

async validate(accessToken: string): Promise<CreateUserDto> {
const logger = new Logger();
logger.debug(`42 access token = ${accessToken}`);
const profile = await this.authService.fetchProfileInformations(accessToken);
return profile;
}
Expand Down
1 change: 1 addition & 0 deletions front/src/pages/OauthCallback.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export default function OauthCallback() {
}

const UseCodeToGetToken = (props: { code: string }) => {
console.log('[UseCodeToGetToken] code =', props.code);
const query1 = useApi().get('send oauth code', '/auth/42/callback', {
params: { code: props.code },
}) as UseQueryResult<tokenDto>;
Expand Down

0 comments on commit 5f4ccea

Please sign in to comment.