diff options
Diffstat (limited to 'juick-server/src/main/java/com/juick')
-rw-r--r-- | juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java b/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java index c6fac269..bc631a1a 100644 --- a/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java +++ b/juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java @@ -45,6 +45,7 @@ import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.CookieValue; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.util.UriComponentsBuilder; import javax.annotation.PostConstruct; import javax.inject.Inject; @@ -70,7 +71,9 @@ public class SocialLogin { private String FACEBOOK_APPID; @Value("${facebook_secret:secret}") private String FACEBOOK_SECRET; - private static final String FACEBOOK_REDIRECT = "https://juick.com/_fblogin"; + @Value("${ap_base_uri:http://localhost:8080/}") + private String baseUri; + private String facebookRedirectUri; private static final String VK_REDIRECT = "http://juick.com/_vklogin"; private static final String TWITTER_VERIFY_URL = "https://api.twitter.com/1.1/account/verify_credentials.json"; @Inject @@ -102,6 +105,8 @@ public class SocialLogin { facebookBuilder = new ServiceBuilder(FACEBOOK_APPID); twitterBuilder = new ServiceBuilder(twitterConsumerKey); vkBuilder = new ServiceBuilder(VK_APPID); + UriComponentsBuilder facebookRedirectBuilder = UriComponentsBuilder.fromUriString(baseUri); + facebookRedirectUri = facebookRedirectBuilder.replacePath("/_fblogin").build().toUriString(); } @GetMapping("/_fblogin") @@ -117,7 +122,7 @@ public class SocialLogin { crosspostService.addFacebookState(fbstate, state); OAuth20Service facebookAuthService = facebookBuilder .apiSecret(FACEBOOK_SECRET) - .callback(FACEBOOK_REDIRECT) + .callback(facebookRedirectUri) .scope("email") .state(fbstate) .build(FacebookApi.instance()); @@ -132,7 +137,7 @@ public class SocialLogin { OAuth20Service facebookService = facebookBuilder .apiKey(FACEBOOK_APPID) .apiSecret(FACEBOOK_SECRET) - .callback(FACEBOOK_REDIRECT) + .callback(facebookRedirectUri) .scope("email") .state(state) .build(FacebookApi.instance()); |