From afd0d2935d35c2daf0d09a585bc505f5c96fd64f Mon Sep 17 00:00:00 2001 From: "Torsten Schulz (local)" Date: Fri, 15 May 2026 09:27:30 +0200 Subject: [PATCH] Add method to generate unique IDs for AuthIdentity records in OAuthService Implement getNextAuthIdentityId to ensure unique ID assignment during OAuth identity creation. Update existing identity creation calls to utilize this new method, enhancing data integrity in the OAuth flow. --- backend/src/services/OAuthService.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/src/services/OAuthService.js b/backend/src/services/OAuthService.js index 1cd2e81..c166036 100644 --- a/backend/src/services/OAuthService.js +++ b/backend/src/services/OAuthService.js @@ -70,6 +70,7 @@ class OAuthService { } authIdentity = await AuthIdentity.create({ + id: await this.getNextAuthIdentityId(AuthIdentity), auth_info_id: authInfo.id, provider, identity: providerId, @@ -127,6 +128,7 @@ class OAuthService { // OAuth-Identity erstellen authIdentity = await AuthIdentity.create({ + id: await this.getNextAuthIdentityId(AuthIdentity), auth_info_id: authInfo.id, provider, identity: providerId, @@ -139,6 +141,11 @@ class OAuthService { return this.createLoginResult(user, authInfo, provider); } + async getNextAuthIdentityId(AuthIdentity) { + const maxId = await AuthIdentity.max('id'); + return Number(maxId || 0) + 1; + } + createPendingToken(profile, provider) { return jwt.sign( { @@ -288,4 +295,3 @@ class OAuthService { } module.exports = new OAuthService(); -