Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于6-7重构社交登陆 #13

Open
qiaolin-li opened this issue Dec 7, 2018 · 1 comment
Open

关于6-7重构社交登陆 #13

qiaolin-li opened this issue Dec 7, 2018 · 1 comment

Comments

@qiaolin-li
Copy link

jojo老师,我有一个疑问,就是您在视频中是如果用户没登陆就去登陆的接口

 @RequestMapping("/social/signUp")
    @ResponseStatus(HttpStatus.UNAUTHORIZED)
    public SocialUserInfo socialInfo(HttpServletRequest request){
        Connection<?> connection = providerSignInUtils.getConnectionFromSession(new ServletWebRequest(request));
        SocialUserInfo socialUserInfo = new SocialUserInfo();
        ConnectionKey key = connection.getKey();
        socialUserInfo.setProviderId(key.getProviderId());
        socialUserInfo.setProviderUserId(key.getProviderUserId());
        socialUserInfo.setNickName(connection.getDisplayName());
        socialUserInfo.getHeadImg();
        appSignUpUtils.saveConnectionData(new ServletWebRequest(request), connection.createData());
        return socialUserInfo;

    }

这是接口,关键是如果是app的话根本无法跳转到这里,然而在这个方法中您使用的是providerSignInUtils.getConnectionFromSession(new ServletWebRequest(request));来获取,此时app已经输入第二次发送请求了,您是在测试工具上应该也会带上session,所以获取到了第一次的connection,如果说是app呢?会拿得到吗?估计有点悬...

其实我有个好主意,利用认证错误处理器来做,这个时候还是属于第一次请求,我可以通过这个 providerSignInUtils来获取到,然后保存到redis中!然后写回去用户信息!这样也就不会发生跳转了!当错误处理器处理后,他也不会跳转页面!因为他会抛出 SocialAuthenticationRedirectException 这个类型i的异常,我还可以检查是这个异常就这样处理!

@momokanni
Copy link

App无需跳转到这里,再仔细看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants