use of org.springframework.social.connect.ConnectionData in project nixmash-blog by mintster.
the class SocialSignInAdapter method signIn.
@Override
public String signIn(String localUserId, Connection<?> connection, NativeWebRequest request) {
User user = userRepository.findByUsername(localUserId);
ConnectionData connectionData = connection.createData();
SignInUtils.authorizeUser(user);
SignInUtils.setUserConnection(request, connectionData);
return null;
}
use of org.springframework.social.connect.ConnectionData in project paascloud-master by paascloud.
the class AppSingUpUtils method doPostSignUp.
/**
* 将缓存的社交网站用户信息与系统注册用户信息绑定
*
* @param request the request
* @param userId the user id
*/
public void doPostSignUp(WebRequest request, String userId) {
String key = getKey(request);
if (!redisTemplate.hasKey(key)) {
throw new AppSecretException("无法找到缓存的用户社交账号信息");
}
ConnectionData connectionData = (ConnectionData) redisTemplate.opsForValue().get(key);
Connection<?> connection = connectionFactoryLocator.getConnectionFactory(connectionData.getProviderId()).createConnection(connectionData);
usersConnectionRepository.createConnectionRepository(userId).addConnection(connection);
redisTemplate.delete(key);
}
use of org.springframework.social.connect.ConnectionData in project theskeleton by codenergic.
the class SocialConnectionService method addConnection.
@Override
@Transactional
public void addConnection(Connection<?> connection) {
ConnectionData data = connection.createData();
int rank = connectionRepository.getRank(userId, data.getProviderId());
SocialConnectionEntity userConnection = new SocialConnectionEntity().setUser(new UserEntity().setId(userId)).setProvider(data.getProviderId()).setProviderUserId(data.getProviderUserId()).setRank(rank).setDisplayName(data.getDisplayName()).setProfileUrl(data.getProfileUrl()).setImageUrl(data.getImageUrl()).setAccessToken(encrypt(data.getAccessToken())).setSecret(encrypt(data.getSecret())).setRefreshToken(encrypt(data.getRefreshToken())).setExpireTime(data.getExpireTime());
connectionRepository.save(userConnection);
}
use of org.springframework.social.connect.ConnectionData in project theskeleton by codenergic.
the class SocialConnectionService method updateConnection.
@Override
@Transactional
public void updateConnection(Connection<?> connection) {
ConnectionData data = connection.createData();
SocialConnectionEntity userConnection = connectionRepository.findByUserIdAndProviderAndProviderUserId(userId, data.getProviderId(), data.getProviderUserId()).orElseThrow(() -> new NoSuchConnectionException(connection.getKey())).setDisplayName(data.getDisplayName()).setProfileUrl(data.getProfileUrl()).setImageUrl(data.getImageUrl()).setAccessToken(encrypt(data.getAccessToken())).setSecret(encrypt(data.getSecret())).setRefreshToken(encrypt(data.getRefreshToken())).setExpireTime(data.getExpireTime());
connectionRepository.save(userConnection);
}
Aggregations