Hi Keith,
Yes, I am sending a POST request to /signin/facebook backed by the ProviderSignInController. One thing I had done differently than the showcase example was that I used <fb:login-button> instead of a standard submit button. Once this was changed to a standard submit button the authorisation process happens as before but now I am being redirect to /signin/facebook. Ideally this should be /signup. Maybe I am missing a configuration somewhere. Given below are my configurations.
Code:
<form id="fb_signin" action="<c:url value="/signin/facebook"/>" method="POST">
<button type="submit"><img src="<c:url value="images/social/facebook/sign-in-with-facebook.png"/>"/></button>
</form>
Code:
@Configuration
public class SocialConfig {
//@Inject
//private Environment environment;
@Inject
private DataSource dataSource;
@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionFactoryLocator connectionFactoryLocator() {
ConnectionFactoryRegistry registry = new ConnectionFactoryRegistry();
registry.addConnectionFactory(new FacebookConnectionFactory(
"<appID>",
"<appSecret>"));
return registry;
}
@Bean
@Scope(value = "singleton", proxyMode = ScopedProxyMode.INTERFACES)
public UsersConnectionRepository usersConnectionRepository() {
return new JdbcUsersConnectionRepository(dataSource, connectionFactoryLocator(), Encryptors.noOpText());
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public ConnectionRepository connectionRepository() {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if (authentication == null) {
throw new IllegalStateException("Unable to get a ConnectionRepository: no user signed in");
}
return usersConnectionRepository().createConnectionRepository(authentication.getName());
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Facebook facebook() {
Connection<Facebook> facebook = connectionRepository().findPrimaryConnection(Facebook.class);
return facebook != null ? facebook.getApi() : new FacebookTemplate();
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.INTERFACES)
public Twitter twitter() {
Connection<Twitter> twitter = connectionRepository().findPrimaryConnection(Twitter.class);
return twitter != null ? twitter.getApi() : new TwitterTemplate();
}
// @Bean
// public ConnectController connectController() {
// ConnectController connectController = new ConnectController(connectionFactoryLocator(), connectionRepository());
// connectController.addInterceptor(new PostToWallAfterConnectInterceptor());
// connectController.addInterceptor(new TweetAfterConnectInterceptor());
// return connectController;
// }
@Bean
public ProviderSignInController providerSignInController() {
ProviderSignInController controller = new ProviderSignInController(connectionFactoryLocator(),
usersConnectionRepository(), new SimpleSignInAdapter());
URL appUrl = null;
try {
appUrl= new URL("<my-app-url>");
}
catch (Exception e) {
}
controller.setApplicationUrl(appUrl);
return controller;
}
}