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:
@@ -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();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user