Skip to content

Commit

Permalink
Remove redundant DatabaseHelper foreign collection assigning in AuthA…
Browse files Browse the repository at this point in the history
…ccountFactory
  • Loading branch information
bivashy committed Jul 10, 2023
1 parent 7d081d7 commit 14f1830
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 16 deletions.
5 changes: 2 additions & 3 deletions core/src/main/java/me/mastercapexd/auth/BaseAuthPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,9 @@ private void initializeBasic() {
}

this.authenticationStepContextFactoryBucket = new BaseAuthenticationStepContextFactoryBucket(config.getAuthenticationSteps());
DatabaseHelper databaseHelper = new DatabaseHelper(this);
this.accountFactory = new AuthAccountFactory(databaseHelper);
this.accountFactory = new AuthAccountFactory();
this.linkTypeProvider = BaseLinkTypeProvider.allLinks();
this.accountDatabase = new AuthAccountDatabaseProxy(databaseHelper);
this.accountDatabase = new AuthAccountDatabaseProxy(new DatabaseHelper(this));
this.loginManagement = new BaseLoginManagement(this);

this.registerAuthenticationSteps();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,18 @@
package me.mastercapexd.auth.account.factory;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.UUID;

import com.bivashy.auth.api.account.Account;
import com.bivashy.auth.api.type.IdentifierType;

import me.mastercapexd.auth.account.AuthAccountAdapter;
import me.mastercapexd.auth.database.DatabaseHelper;
import me.mastercapexd.auth.database.model.AuthAccount;

public class AuthAccountFactory extends AccountFactoryTemplate {
private final DatabaseHelper databaseHelper;

public AuthAccountFactory(DatabaseHelper databaseHelper) {
this.databaseHelper = databaseHelper;
}

@Override
protected Account newAccount(String id, IdentifierType identifierType, UUID uniqueId, String name) {
AuthAccount authAccount = new AuthAccount(id, identifierType, name, uniqueId);
try {
databaseHelper.getAuthAccountDao().assignEmptyForeignCollection(authAccount, "links");
} catch(SQLException e) {
e.printStackTrace();
}
return new AuthAccountAdapter(authAccount, new ArrayList<>());
}
}

0 comments on commit 14f1830

Please sign in to comment.