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.
This commit is contained in:
Torsten Schulz (local)
2026-05-15 09:27:30 +02:00
parent c23d260bdc
commit afd0d2935d

View File

@@ -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();