1

我正在使用 Spring Social LinkedIn 使用自定义 ConnectController 检索用户配置文件,因为我希望用户一步登录并检索配置文件。问题是有时会返回系统中的第一个用户,而不是当前登录的用户。

这是我的 CustomConnectController

@Controller
@RequestMapping("/connect")
public class CustomConnectController extends ConnectController {

    @Inject
    public CustomConnectController(ConnectionFactoryLocator connectionFactoryLocator,
            ConnectionRepository connectionRepository) {
        super(connectionFactoryLocator, connectionRepository);
    }

    @Override
    protected String connectView(String providerId) {
        return "redirect:/hey/" + providerId + "Connect";
    }

    @Override
    protected String connectedView(String providerId) {
        return "redirect:/hey/" + providerId + "Connected";
    }
    }

和我的网络控制器

@Controller
public class WebController {    

    @Autowired
    private LinkedIn linkedin;

    @Autowired
    private ConnectionRepository repository;


    @RequestMapping(value = "/hey/linkedinConnected", method = RequestMethod.GET)
    public String linkedinConnected(HttpServletRequest request, Model model, Locale locale) {
        if (repository.findConnections("linkedin").isEmpty()
                || !linkedin.isAuthorized()) {
            return "redirect:/connect/linkedin";
        }
        LinkedInProfile userProfile = linkedin.profileOperations().getUserProfile();
        return "loggedinpage";
    }

    @RequestMapping(value = "/hey/linkedinConnect", method = RequestMethod.GET)
    public String linkedinConnect(HttpServletRequest request, Model model, Locale locale) {
        if (repository.findConnections("linkedin").isEmpty()
                || !linkedin.isAuthorized()) {
            return "redirect:/connect/linkedin";
        }
        LinkedInProfile userProfile = linkedin.profileOperations().getUserProfile();
        return "loggedinpage";
    }

}

关于我做错了什么的任何想法?

4

0 回答 0