Skip to content

Commit

Permalink
fix(authentication): apple data not stored
Browse files Browse the repository at this point in the history
  • Loading branch information
kkopanidis committed Mar 27, 2024
1 parent 4b28b9f commit db2150c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/authentication/src/handlers/oauth2/apple/apple.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ import {
} from '../interfaces/index.js';
import axios from 'axios';
import { AppleUser } from './apple.user.js';
import jwt from 'jsonwebtoken';
import { Jwt, JwtHeader, JwtPayload } from 'jsonwebtoken';
import jwt, { Jwt, JwtHeader, JwtPayload } from 'jsonwebtoken';
import { TokenProvider } from '../../tokenProvider.js';
import { Token } from '../../../models/index.js';
import { status } from '@grpc/grpc-js';
Expand Down Expand Up @@ -126,10 +125,17 @@ export class AppleHandlers extends OAuth2<AppleUser, AppleOAuth2Settings> {
if (decoded_id_token!.payload.sub !== payload.sub) {
throw new GrpcError(status.INVALID_ARGUMENT, 'Invalid token');
}
let userData = params.user;
try {
userData = JSON.parse(params.user);
} catch (e) {
// already a valid object
}

const userParams = {
id: payload.sub!,
email: payload.email,
data: { ...payload.email_verified },
data: { ...userData, ...payload.email_verified },
};
const user = await this.createOrUpdateUser(
userParams,
Expand Down

0 comments on commit db2150c

Please sign in to comment.