From b38a6f9c57fcc9fbe0605c698ec94a405312b246 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 7 Apr 2017 11:07:50 +0300 Subject: juick-www: refactor social logins --- .../java/com/juick/www/controllers/TwitterAuth.java | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java') diff --git a/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java b/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java index 8ccaecfa..741fb95f 100644 --- a/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java +++ b/juick-www/src/main/java/com/juick/www/controllers/TwitterAuth.java @@ -10,7 +10,7 @@ import com.github.scribejava.core.model.Verb; import com.github.scribejava.core.oauth.OAuth10aService; import com.juick.service.UserService; import org.apache.commons.lang3.StringUtils; -import org.springframework.core.env.Environment; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; @@ -29,7 +29,10 @@ public class TwitterAuth { private final static String VERIFY_URL = "https://api.twitter.com/1.1/account/verify_credentials.json"; - private String consumerKey, consumerSecret; + @Value("${twitter_consumer_key}") + private String consumerKey; + @Value("${twitter_consumer_secret}") + private String consumerSecret; @Inject private ObjectMapper jsonMapper; @@ -37,10 +40,10 @@ public class TwitterAuth { @Inject UserService userService; - @Inject - public TwitterAuth(Environment env) { - this.consumerKey = env.getProperty("twitter_consumer_key"); - this.consumerSecret = env.getProperty("twitter_consumer_secret"); + private ServiceBuilder serviceBuilder; + + public TwitterAuth() { + serviceBuilder = new ServiceBuilder(); } @GetMapping("/_twitter") @@ -65,7 +68,7 @@ public class TwitterAuth { response.sendError(HttpServletResponse.SC_FORBIDDEN); return; } - OAuth10aService oAuthService = new ServiceBuilder() + OAuth10aService oAuthService = serviceBuilder .apiKey(consumerKey) .apiSecret(consumerSecret) .callback("http://juick.com/_twitter") -- cgit v1.2.3