Spring Social возвращает неправильный профиль пользователя
Я использую 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";
}
}
Есть идеи, что я делаю не так?