// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/AuthenticationUtil.java
// @Slf4j
// public class AuthenticationUtil {
// 
//     public static void authenticate(Connection<?> connection) {
//         Player player = Player.builder()
//                 .username(connection.getDisplayName())
//                 .url(connection.getProfileUrl())
//                 .image(connection.getImageUrl())
//                 .build();
//         UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(player.getUsername(), "", Collections.emptyList());
//         SecurityContextHolder.getContext().setAuthentication(authenticationToken);
// 
//         log.info("User {} connected successfully", player.getUsername());
//     }
// }


import be.ordina.jworks.rpsls.configuration.AuthenticationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;
package be.ordina.jworks.rpsls.controller;


@Slf4j
@Controller
public class SignupController {

    private final ProviderSignInUtils providerSignInUtils;

    @Autowired
    public SignupController(final ConnectionFactoryLocator connectionFactoryLocator, final UsersConnectionRepository usersConnectionRepository) {
        this.providerSignInUtils = new ProviderSignInUtils(connectionFactoryLocator, usersConnectionRepository);
    }

    @RequestMapping("/signup")
    public String signup(final WebRequest webRequest) {
        Connection<?> connection = providerSignInUtils.getConnectionFromSession(webRequest);

        if (connection != null) {
// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/configuration/AuthenticationUtil.java
// @Slf4j
// public class AuthenticationUtil {
// 
//     public static void authenticate(Connection<?> connection) {
//         Player player = Player.builder()
//                 .username(connection.getDisplayName())
//                 .url(connection.getProfileUrl())
//                 .image(connection.getImageUrl())
//                 .build();
//         UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(player.getUsername(), "", Collections.emptyList());
//         SecurityContextHolder.getContext().setAuthentication(authenticationToken);
// 
//         log.info("User {} connected successfully", player.getUsername());
//     }
// }


// Path: rock-paper-scissors-lizard-spock/src/main/java/be/ordina/jworks/rpsls/controller/SignupController.java
import be.ordina.jworks.rpsls.configuration.AuthenticationUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.ConnectionFactoryLocator;
import org.springframework.social.connect.UsersConnectionRepository;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.context.request.WebRequest;

package be.ordina.jworks.rpsls.controller;


@Slf4j
@Controller
public class SignupController {

    private final ProviderSignInUtils providerSignInUtils;

    @Autowired
    public SignupController(final ConnectionFactoryLocator connectionFactoryLocator, final UsersConnectionRepository usersConnectionRepository) {
        this.providerSignInUtils = new ProviderSignInUtils(connectionFactoryLocator, usersConnectionRepository);
    }

    @RequestMapping("/signup")
    public String signup(final WebRequest webRequest) {
        Connection<?> connection = providerSignInUtils.getConnectionFromSession(webRequest);

        if (connection != null) {
            AuthenticationUtil.authenticate(connection);