com.healthy.security.app.AppSecurityController Maven / Gradle / Ivy
package com.healthy.security.app;
import com.healthy.common.security.properties.SecurityConstants;
import com.healthy.common.security.social.SocialController;
import com.healthy.common.security.social.support.SocialUserInfo;
import com.healthy.security.app.social.AppSignInUtils;
import org.springframework.http.HttpStatus;
import org.springframework.social.connect.Connection;
import org.springframework.social.connect.web.ProviderSignInUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.ServletWebRequest;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
/**
* AppSecurityController
*
* @author xiaomingzhang
*/
@RestController
public class AppSecurityController extends SocialController {
@Resource
private ProviderSignInUtils providerSignInUtils;
@Resource
private AppSignInUtils appSingUpUtils;
/**
* When the user logs in for the first time, guide the user to register or bind This
* service is used to obtain social networking site user information on the
* registration or binding page
* @param request the current request attributes
* @return SocialUserInfo
*/
@GetMapping(SecurityConstants.DEFAULT_SOCIAL_USER_INFO_URL)
@ResponseStatus(HttpStatus.UNAUTHORIZED)
public SocialUserInfo getSocialUserInfo(HttpServletRequest request) {
Connection> connection = providerSignInUtils.getConnectionFromSession(new ServletWebRequest(request));
appSingUpUtils.saveConnectionData(new ServletWebRequest(request), connection.createData());
return buildSocialUserInfo(connection);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy