So im building a web application on spring boot security.
my application currently allows you to register & login locally, or you can login using a server provider that is google & linkedin. after registering, it asks you to submit a number of bitcoins, then it saves it to DB in your profile.
every time you register with different provider, it will save in the DB a new profile, the common thing is the email. but the bitcoins will differ since every profile is separated.
what i want to do is sum up the attribute "bitcoin" for those who has the same email (different providers, one email) to display it in each page with same value.
i'm using this class to access my DB
public interface UserRepository extends JpaRepository<User, Long> {
User findByRegName(String regName);
}
and this is in the main controller to view the bitcoins in the authenticated user page.
public String wallet(Model model) {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
String regName = authentication.getName();
User user = userRepository.findByRegName(regName);
model.addAttribute("user", user);
return "wallet";
}
please note that im a beginner in coding. a simple explaination would be appreciated
also if you need extra code to be displayed let me know