src/main/java/edu/kea/kab/service/UserService.java
public void addUser(User user) {

        // Set the password to the password given by the user and encode it
        user.setPassword(passwordEncoder.encode(user.getPassword()));
        userRepository.save(user);

        // Instantiating a Authorization object and setting its userId to match the new user and role to user
        Authorization authorization = new Authorization();
        authorization.setUserId(user.getId());
        authorization.setRole(Role.ROLE_USER);
        authorizationRepository.save(authorization);

    }
// Add a user to the DB, giving that user a ROLE_USER in the authorization table
Add a user to the DB, giving that user a ROLE_USER in the authorization table
Add a user to the DB giving that user a ROLE_USER in the authorization table
public void addUser(User user) {
        user.setPassword(passwordEncoder.encode(user.getPassword()));
        userRepository.save(user);
        Authorization authorization = new Authorization();
        authorization.setUserId(user.getId());
        authorization.setRole(Role.ROLE_USER);
        authorizationRepository.save(authorization);
    }
public void addUser ( User user ) { user . setPassword ( passwordEncoder . encode ( user . getPassword ( ) ) ) ; userRepository . save ( user ) ; Authorization authorization = new Authorization ( ) ; authorization . setUserId ( user . getId ( ) ) ; authorization . setRole ( Role . ROLE_USER ) ; authorizationRepository . save ( authorization ) ; }
Add a user to the DB, giving that user a ROLE_USER in the authorization table
Add a user to the DB giving that user a ROLE_USER in the authorization table
// Set the password to the password given by the user and encode it // Instantiating a Authorization object and setting its userId to match the new user and role to user