我成功完成了注册流程并注册了用户配置文件,并在用户连接表中创建了一条记录。
我正在使用Spring-social with Spring security遵循此blog
中提到的步骤现在我的问题是在旅程2上,这意味着用户已经使用Facebook注册,需要使用Facebook登录。我能够以这种方式设置帖子登录网址
SpringSocialConfigurer sc = new SpringSocialConfigurer();
sc.postLoginUrl("/account/social");
并将其添加到安全过滤器链中。
因此调用此方法,但连接始终为null。实际上我想获取登录用户的用户ID和用户名
@RequestMapping(value="/account/social", method = { RequestMethod.GET})
public void resendUsl(HttpServletRequest request,WebRequest request1, HttpServletResponse response,Model model) throws IOException {
System.out.println("here");
Connection<?> connection = ProviderSignInUtils.getConnection(request1);
我已经尝试创建了一个类SimpleSignInAdaptor
但是这个调用根本没有来到这里。
public class SimpleSignInAdaptor implements SignInAdapter {
如何在登录成功后获取用户详细信息?
感谢您的帮助
更新以这种方式解决,但如果用户在facebook和Twitter帐户注册并尝试使用其中任何一个登录,则会出现此问题。它始终通过连接存储库
@Inject private ConnectionRepository connectionRepository;
@RequestMapping(value="/social", method = { RequestMethod.GET})
public void resendUsl(HttpServletRequest request,WebRequest request1, HttpServletResponse response,Model model) throws IOException {
Connection<Facebook> connection = connectionRepository.findPrimaryConnection(Facebook.class);