aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main/java/com
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-10-04 10:38:50 +0300
committerGravatar Vitaly Takmazov2018-10-04 10:38:50 +0300
commit7f9187d8a87a5cd6e2720eac0d03f1c2fcc507ed (patch)
tree02a2aba53fdd46fa6b279c72285d270b38997749 /juick-server/src/main/java/com
parente4a25d3a3820f9fdc03d6625f1e666335739de76 (diff)
facebook redirect uri from base uri
Diffstat (limited to 'juick-server/src/main/java/com')
-rw-r--r--juick-server/src/main/java/com/juick/server/www/controllers/SocialLogin.java11
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());