From b34f60e44fa5a4d3fa89e5eac9f8698c13a096f1 Mon Sep 17 00:00:00 2001 From: johnsonpham Date: Thu, 8 Jan 2015 18:06:46 +0700 Subject: [PATCH 01/14] remove tour guide --- src/main/webapp/assets/modules/common/tour.ser.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/webapp/assets/modules/common/tour.ser.js b/src/main/webapp/assets/modules/common/tour.ser.js index b1a279334..e2afce7ff 100644 --- a/src/main/webapp/assets/modules/common/tour.ser.js +++ b/src/main/webapp/assets/modules/common/tour.ser.js @@ -37,9 +37,9 @@ angular.module("Common").factory("tourService", function (jsonValue, utils) { // instance.endTourGuide(); //}); - utils.registerNotification(jsonValue.notifications.gotData, function () { - instance.makeTourGuide(); - }); + //utils.registerNotification(jsonValue.notifications.gotData, function () { + // instance.makeTourGuide(); + //}); //$('body').on('click', function (e) { // var container = $(".tour"); From f9fcd48a585db888da2486201278131141db9744 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Thu, 8 Jan 2015 18:10:50 +0700 Subject: [PATCH 02/14] Remove "key" in userModel --- .../techlooper/config/CoreConfiguration.java | 13 ++++++++-- .../controller/SocialController.java | 8 +++++-- .../techlooper/controller/UserController.java | 10 +++++++- .../com/techlooper/entity/UserEntity.java | 15 ------------ .../com/techlooper/model/SocialRequest.java | 10 ++++++++ .../service/impl/AbstractSocialService.java | 4 ++-- .../service/impl/FacebookService.java | 3 +-- .../service/impl/GitHubService.java | 3 +-- .../service/impl/GoogleService.java | 3 +-- .../service/impl/LinkedInService.java | 3 +-- .../service/impl/TwitterService.java | 3 +-- .../service/impl/UserServiceImpl.java | 24 ++++++++++--------- src/main/resources/couchbase_view/byKey.js | 4 ---- src/main/resources/dev/techlooper.properties | 4 +++- .../resources/local/techlooper.properties | 4 +++- src/main/webapp/assets/modules/app.js | 4 +++- .../assets/modules/common/connection.fac.js | 6 +++-- .../assets/modules/common/history.fac.js | 2 +- .../assets/modules/signin/signin.ser.js | 4 ++-- 19 files changed, 72 insertions(+), 55 deletions(-) delete mode 100644 src/main/resources/couchbase_view/byKey.js diff --git a/src/main/java/com/techlooper/config/CoreConfiguration.java b/src/main/java/com/techlooper/config/CoreConfiguration.java index 0ccf13e33..c174405a8 100644 --- a/src/main/java/com/techlooper/config/CoreConfiguration.java +++ b/src/main/java/com/techlooper/config/CoreConfiguration.java @@ -14,12 +14,15 @@ import org.dozer.loader.api.TypeMappingOptions; import org.jasypt.util.password.PasswordEncryptor; import org.jasypt.util.password.StrongPasswordEncryptor; +import org.jasypt.util.text.BasicTextEncryptor; +import org.jasypt.util.text.TextEncryptor; import org.springframework.cache.CacheManager; import org.springframework.cache.annotation.EnableCaching; import org.springframework.cache.concurrent.ConcurrentMapCacheManager; import org.springframework.cache.support.CompositeCacheManager; import org.springframework.context.annotation.*; import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; +import org.springframework.core.env.Environment; import org.springframework.scheduling.annotation.EnableScheduling; import org.springframework.social.facebook.api.FacebookProfile; import org.springframework.social.google.api.plus.Person; @@ -27,6 +30,7 @@ import org.springframework.web.multipart.MultipartResolver; import org.springframework.web.multipart.commons.CommonsMultipartResolver; +import javax.annotation.Resource; import java.util.Arrays; @Configuration @@ -39,6 +43,9 @@ @EnableCaching(proxyTargetClass = true) public class CoreConfiguration { + @Resource + private Environment environment; + @Bean public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); @@ -101,8 +108,10 @@ protected void configure() { } @Bean - public PasswordEncryptor passwordEncryptor() { - return new StrongPasswordEncryptor(); + public TextEncryptor textEncryptor() { + BasicTextEncryptor textEncryptor = new BasicTextEncryptor(); + textEncryptor.setPassword(environment.getProperty("core.textEncryptor.password")); + return textEncryptor; } } diff --git a/src/main/java/com/techlooper/controller/SocialController.java b/src/main/java/com/techlooper/controller/SocialController.java index bdb03b7fc..638540af3 100644 --- a/src/main/java/com/techlooper/controller/SocialController.java +++ b/src/main/java/com/techlooper/controller/SocialController.java @@ -8,6 +8,7 @@ import com.techlooper.model.SocialResponse; import com.techlooper.repository.JsonConfigRepository; import com.techlooper.service.SocialService; +import org.jasypt.util.text.TextEncryptor; import org.springframework.context.ApplicationContext; import org.springframework.stereotype.Controller; import org.springframework.util.StringUtils; @@ -32,6 +33,9 @@ public class SocialController { @Resource private JsonConfigRepository jsonConfigRepository; + @Resource + private TextEncryptor textEncryptor; + @ResponseBody @RequestMapping("/getSocialConfig") public List getSocialConfig(@RequestParam("providers[]") List providers) { @@ -53,7 +57,7 @@ public SocialResponse auth(@PathVariable SocialProvider provider, UserEntity userEntity = StringUtils.hasText(key) ? service.saveFootprint(accessGrant, key) : service.saveFootprint(accessGrant); return SocialResponse.Builder.get() .withToken(accessGrant.getAccessToken()) - .withKey(userEntity.getKey()).build(); + .withKey(textEncryptor.encrypt(userEntity.getEmailAddress())).build(); } @ResponseBody @@ -68,7 +72,7 @@ public SocialResponse auth1(@PathVariable SocialProvider provider, HttpServletRe UserEntity userEntity = StringUtils.hasText(key) ? service.saveFootprint(accessGrant, key) : service.saveFootprint(accessGrant); return SocialResponse.Builder.get() .withToken(accessGrant.getValue()) - .withKey(userEntity.getKey()).build(); + .withKey(textEncryptor.encrypt(userEntity.getEmailAddress())).build(); } AccessGrant accessGrant = service.getAccessGrant(null, null); httpServletResponse.sendRedirect(accessGrant.getAuthorizeUrl()); diff --git a/src/main/java/com/techlooper/controller/UserController.java b/src/main/java/com/techlooper/controller/UserController.java index 7858ee9ce..97a75efc7 100644 --- a/src/main/java/com/techlooper/controller/UserController.java +++ b/src/main/java/com/techlooper/controller/UserController.java @@ -3,6 +3,7 @@ import com.techlooper.model.SocialRequest; import com.techlooper.model.UserInfo; import com.techlooper.service.UserService; +import org.jasypt.util.text.TextEncryptor; import org.springframework.messaging.handler.annotation.MessageMapping; import org.springframework.messaging.simp.annotation.SendToUser; import org.springframework.stereotype.Controller; @@ -17,6 +18,7 @@ import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.util.List; +import java.util.Optional; /** * Created by phuonghqh on 12/23/14. @@ -27,6 +29,9 @@ public class UserController { @Resource private UserService userService; + @Resource + private TextEncryptor textEncryptor; + @ResponseBody @RequestMapping(value = "/user/save", method = RequestMethod.POST) public List save(@RequestBody @Valid UserInfo userInfo, BindingResult result, HttpServletResponse httpServletResponse) { @@ -52,6 +57,9 @@ public UserInfo getUserInfo(@RequestBody @Valid SocialRequest searchRequest/*, @ @ResponseBody @RequestMapping(value = "/user/verifyUserLogin", method = RequestMethod.POST) - public void verifyUserLogin(@RequestBody(required = false) SocialRequest searchRequest) { + public void verifyUserLogin(@RequestBody @Valid SocialRequest searchRequest, HttpServletResponse httpServletResponse) { + if (!textEncryptor.decrypt(searchRequest.getKey()).equals(searchRequest.getEmailAddress())) { + httpServletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN); + } } } diff --git a/src/main/java/com/techlooper/entity/UserEntity.java b/src/main/java/com/techlooper/entity/UserEntity.java index 825bc9a83..0de0756c9 100644 --- a/src/main/java/com/techlooper/entity/UserEntity.java +++ b/src/main/java/com/techlooper/entity/UserEntity.java @@ -28,8 +28,6 @@ public class UserEntity { private AccessGrant accessGrant; - private String key; - private String username; private Integer salary; @@ -60,14 +58,6 @@ public void setUsername(String username) { this.username = username; } - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - public AccessGrant getAccessGrant() { return accessGrant; } @@ -151,11 +141,6 @@ public UserEntityBuilder withAccessGrant(AccessGrant accessGrant) { return this; } - public UserEntityBuilder withKey(String key) { - userEntity.key = key; - return this; - } - public UserEntity build() { return userEntity; } diff --git a/src/main/java/com/techlooper/model/SocialRequest.java b/src/main/java/com/techlooper/model/SocialRequest.java index a319af666..c312cd559 100644 --- a/src/main/java/com/techlooper/model/SocialRequest.java +++ b/src/main/java/com/techlooper/model/SocialRequest.java @@ -10,6 +10,16 @@ public class SocialRequest { @NotNull private String key; + private String emailAddress; + + public String getEmailAddress() { + return emailAddress; + } + + public void setEmailAddress(String emailAddress) { + this.emailAddress = emailAddress; + } + public String getKey() { return key; } diff --git a/src/main/java/com/techlooper/service/impl/AbstractSocialService.java b/src/main/java/com/techlooper/service/impl/AbstractSocialService.java index 49b39b039..24311cc3c 100644 --- a/src/main/java/com/techlooper/service/impl/AbstractSocialService.java +++ b/src/main/java/com/techlooper/service/impl/AbstractSocialService.java @@ -8,7 +8,7 @@ import com.techlooper.service.SocialService; import com.techlooper.service.UserService; import org.dozer.Mapper; -import org.jasypt.util.password.PasswordEncryptor; +import org.jasypt.util.text.TextEncryptor; import org.springframework.social.connect.support.OAuth1ConnectionFactory; import org.springframework.social.connect.support.OAuth2ConnectionFactory; import org.springframework.social.oauth1.AuthorizedRequestToken; @@ -35,7 +35,7 @@ public abstract class AbstractSocialService implements SocialService { protected Mapper dozerBeanMapper; @Resource - protected PasswordEncryptor passwordEncryptor; + protected TextEncryptor textEncryptor; protected SocialConfig socialConfig; diff --git a/src/main/java/com/techlooper/service/impl/FacebookService.java b/src/main/java/com/techlooper/service/impl/FacebookService.java index 002b07fda..49b8905c2 100644 --- a/src/main/java/com/techlooper/service/impl/FacebookService.java +++ b/src/main/java/com/techlooper/service/impl/FacebookService.java @@ -58,8 +58,7 @@ public UserEntity saveFootprint(AccessGrant accessGrant) { if (!Optional.ofNullable(userEntity.getEmailAddress()).isPresent()) { dozerBeanMapper.map(profileEntity, userEntity); builder.withId(profileEntity.getEmail()) - .withLoginSource(SocialProvider.FACEBOOK) - .withKey(passwordEncryptor.encryptPassword(profileEntity.getEmail())); + .withLoginSource(SocialProvider.FACEBOOK); } userService.save(userEntity); return userEntity; diff --git a/src/main/java/com/techlooper/service/impl/GitHubService.java b/src/main/java/com/techlooper/service/impl/GitHubService.java index c1571079c..d431f2abd 100644 --- a/src/main/java/com/techlooper/service/impl/GitHubService.java +++ b/src/main/java/com/techlooper/service/impl/GitHubService.java @@ -90,8 +90,7 @@ private UserEntity createUserEntity(AccessGrant accessGrant, Connection profileEntity.setProfileImageUrl(profileImageUrl); dozerBeanMapper.map(profileEntity, userEntity); builder.withId(profileEntity.getEmail()) - .withLoginSource(GITHUB) - .withKey(passwordEncryptor.encryptPassword(profileEntity.getEmail())); + .withLoginSource(GITHUB); } return userEntity; } diff --git a/src/main/java/com/techlooper/service/impl/GoogleService.java b/src/main/java/com/techlooper/service/impl/GoogleService.java index 35c8d7b9c..9af8bfd9c 100644 --- a/src/main/java/com/techlooper/service/impl/GoogleService.java +++ b/src/main/java/com/techlooper/service/impl/GoogleService.java @@ -54,8 +54,7 @@ public UserEntity saveFootprint(AccessGrant accessGrant) { if (!Optional.ofNullable(userEntity.getEmailAddress()).isPresent()) { dozerBeanMapper.map(profile, userEntity); builder.withId(profile.getAccountEmail()) - .withLoginSource(SocialProvider.GITHUB) - .withKey(passwordEncryptor.encryptPassword(profile.getAccountEmail())); + .withLoginSource(SocialProvider.GITHUB); } userService.save(userEntity); return userEntity; diff --git a/src/main/java/com/techlooper/service/impl/LinkedInService.java b/src/main/java/com/techlooper/service/impl/LinkedInService.java index 4fda5a644..8e83826f5 100644 --- a/src/main/java/com/techlooper/service/impl/LinkedInService.java +++ b/src/main/java/com/techlooper/service/impl/LinkedInService.java @@ -56,8 +56,7 @@ public UserEntity saveFootprint(AccessGrant accessGrant) { if (!Optional.ofNullable(entity.getEmailAddress()).isPresent()) { dozerBeanMapper.map(profileEntity, entity); builder.withId(profileEntity.getEmailAddress()) - .withLoginSource(LINKEDIN) - .withKey(passwordEncryptor.encryptPassword(profileEntity.getEmailAddress())); + .withLoginSource(LINKEDIN); } userService.save(entity); return entity; diff --git a/src/main/java/com/techlooper/service/impl/TwitterService.java b/src/main/java/com/techlooper/service/impl/TwitterService.java index e49f0bb02..9073a961e 100644 --- a/src/main/java/com/techlooper/service/impl/TwitterService.java +++ b/src/main/java/com/techlooper/service/impl/TwitterService.java @@ -56,8 +56,7 @@ public UserEntity saveFootprint(AccessGrant accessGrant) { if (!Optional.ofNullable(userEntity.getEmailAddress()).isPresent()) { dozerBeanMapper.map(profile, userEntity); builder.withId(userId) - .withLoginSource(SocialProvider.TWITTER) - .withKey(passwordEncryptor.encryptPassword(userId)); + .withLoginSource(SocialProvider.TWITTER); } userService.save(userEntity); return userEntity; diff --git a/src/main/java/com/techlooper/service/impl/UserServiceImpl.java b/src/main/java/com/techlooper/service/impl/UserServiceImpl.java index 9f5d6cffc..9538d6204 100644 --- a/src/main/java/com/techlooper/service/impl/UserServiceImpl.java +++ b/src/main/java/com/techlooper/service/impl/UserServiceImpl.java @@ -7,6 +7,7 @@ import com.techlooper.repository.couchbase.UserRepository; import com.techlooper.service.UserService; import org.dozer.Mapper; +import org.jasypt.util.text.TextEncryptor; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -23,15 +24,18 @@ public class UserServiceImpl implements UserService { @Resource private Mapper dozerMapper; + @Resource + private TextEncryptor textEncryptor; + public void save(UserEntity userEntity) { userRepository.save(userEntity); - - // TODO: make sure couchbase find by view can work later, remove it later - Query query = new Query(); - query.setKey(userEntity.getKey()); - query.setLimit(1); - query.setStale(Stale.FALSE); - userRepository.findByKey(query); +// +// // TODO: make sure couchbase find by view can work later, remove it later +// Query query = new Query(); +// query.setKey(userEntity.getKey()); +// query.setLimit(1); +// query.setStale(Stale.FALSE); +// userRepository.findByKey(query); } public void save(UserInfo userInfo) { @@ -49,9 +53,7 @@ public UserInfo findUserInfoByKey(String key) { } public UserEntity findUserEntityByKey(String key) { - Query query = new Query(); - query.setKey(key); - query.setLimit(1); - return userRepository.findByKey(query); + String emailAddress = textEncryptor.decrypt(key); + return userRepository.findOne(emailAddress); } } diff --git a/src/main/resources/couchbase_view/byKey.js b/src/main/resources/couchbase_view/byKey.js deleted file mode 100644 index 676142a69..000000000 --- a/src/main/resources/couchbase_view/byKey.js +++ /dev/null @@ -1,4 +0,0 @@ -function (doc, meta) { - if(doc._class == "com.techlooper.entity.UserEntity" ) { emit(doc.key, null); - } -} diff --git a/src/main/resources/dev/techlooper.properties b/src/main/resources/dev/techlooper.properties index 63bdb59e1..ef0de2007 100644 --- a/src/main/resources/dev/techlooper.properties +++ b/src/main/resources/dev/techlooper.properties @@ -13,4 +13,6 @@ couchbase.bucketPassword = 123456 # see the cron configuration table here: http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger scheduled.cron = 0 0/5 * * * * -webapp.resource.location = /public/ \ No newline at end of file +webapp.resource.location = /public/ + +core.textEncryptor.password = XR3hBZnJ6gLH \ No newline at end of file diff --git a/src/main/resources/local/techlooper.properties b/src/main/resources/local/techlooper.properties index 9070b01ed..c21ec33ed 100644 --- a/src/main/resources/local/techlooper.properties +++ b/src/main/resources/local/techlooper.properties @@ -14,4 +14,6 @@ couchbase.bucketPassword = 123456 # see the cron configuration table here: http://www.quartz-scheduler.org/documentation/quartz-1.x/tutorials/crontrigger scheduled.cron = 0 0/5 * * * * -webapp.resource.location = /assets/ \ No newline at end of file +webapp.resource.location = /assets/ + +core.textEncryptor.password = XR3hBZnJ6gLH \ No newline at end of file diff --git a/src/main/webapp/assets/modules/app.js b/src/main/webapp/assets/modules/app.js index 87099dd6c..9d14ddded 100644 --- a/src/main/webapp/assets/modules/app.js +++ b/src/main/webapp/assets/modules/app.js @@ -39,6 +39,8 @@ techlooper.config(["$routeProvider", "$translateProvider", "$authProvider", "loc utils.sendNotification(jsonValue.notifications.loginFailed); } break; + + case 500: case 404: utils.sendNotification(jsonValue.notifications.http404); break; @@ -53,7 +55,7 @@ techlooper.config(["$routeProvider", "$translateProvider", "$authProvider", "loc .setPrefix('techlooper') .setStorageType('sessionStorage') .setNotify(true, true) - .setStorageCookie(45);; + .setStorageCookie(45); $.post("getSocialConfig", {providers: ["LINKEDIN", "FACEBOOK", "GOOGLE", "TWITTER", "GITHUB"]}) .done(function (resp) { diff --git a/src/main/webapp/assets/modules/common/connection.fac.js b/src/main/webapp/assets/modules/common/connection.fac.js index 8ac3ef25c..8424eb1c2 100644 --- a/src/main/webapp/assets/modules/common/connection.fac.js +++ b/src/main/webapp/assets/modules/common/connection.fac.js @@ -67,8 +67,10 @@ angular.module("Common").factory("connectionFactory", var instance = { verifyUserLogin: function() { - return $$.post(jsonValue.httpUri.verifyUserLogin, - {key: localStorageService.cookie.get(jsonValue.storage.key)}); + return $$.post(jsonValue.httpUri.verifyUserLogin, { + key: localStorageService.cookie.get(jsonValue.storage.key), + emailAddress: $rootScope.userInfo !== undefined ? $rootScope.userInfo.emailAddress : "" + }); }, login: function () { diff --git a/src/main/webapp/assets/modules/common/history.fac.js b/src/main/webapp/assets/modules/common/history.fac.js index 9aa064e30..a4fa596c6 100644 --- a/src/main/webapp/assets/modules/common/history.fac.js +++ b/src/main/webapp/assets/modules/common/history.fac.js @@ -28,7 +28,7 @@ angular.module("Common").factory("historyFactory", function (jsonValue, $locatio }, popHistory: function () { - //historyStack.pop(); // remove current item + historyStack.pop(); // remove current item if (historyStack.length === 0) return "/"; return historyStack.pop(); } diff --git a/src/main/webapp/assets/modules/signin/signin.ser.js b/src/main/webapp/assets/modules/signin/signin.ser.js index bee3940d6..72a1e81de 100644 --- a/src/main/webapp/assets/modules/signin/signin.ser.js +++ b/src/main/webapp/assets/modules/signin/signin.ser.js @@ -1,6 +1,6 @@ angular.module('SignIn').factory('signInService', function (jsonValue, utils, shortcutFactory, $location, tourService, $auth, localStorageService, - $window, $http, connectionFactory) { + $window, $http, connectionFactory, $rootScope) { var $$ = { enableNotifications: function () { @@ -25,7 +25,7 @@ angular.module('SignIn').factory('signInService', utils.sendNotification(jsonValue.notifications.loginSuccess); }) .catch(function() { - //utils.sendNotification(jsonValue.notifications.loginFailed); + $rootScope.userInfo = undefined; utils.sendNotification(jsonValue.notifications.loaded); }); From 9343c551a59924b4f4ff1b3eb48d03eee2d286c9 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Thu, 8 Jan 2015 20:58:02 +0700 Subject: [PATCH 03/14] Fix history issue --- src/main/resources/couchbase_view/byKey.js | 0 src/main/webapp/assets/modules/app.js | 2 +- .../webapp/assets/modules/common/history.fac.js | 14 +++++++------- 3 files changed, 8 insertions(+), 8 deletions(-) create mode 100644 src/main/resources/couchbase_view/byKey.js diff --git a/src/main/resources/couchbase_view/byKey.js b/src/main/resources/couchbase_view/byKey.js new file mode 100644 index 000000000..e69de29bb diff --git a/src/main/webapp/assets/modules/app.js b/src/main/webapp/assets/modules/app.js index 9d14ddded..42852530d 100644 --- a/src/main/webapp/assets/modules/app.js +++ b/src/main/webapp/assets/modules/app.js @@ -39,7 +39,7 @@ techlooper.config(["$routeProvider", "$translateProvider", "$authProvider", "loc utils.sendNotification(jsonValue.notifications.loginFailed); } break; - + case 500: case 404: utils.sendNotification(jsonValue.notifications.http404); diff --git a/src/main/webapp/assets/modules/common/history.fac.js b/src/main/webapp/assets/modules/common/history.fac.js index a4fa596c6..b86245611 100644 --- a/src/main/webapp/assets/modules/common/history.fac.js +++ b/src/main/webapp/assets/modules/common/history.fac.js @@ -1,16 +1,14 @@ angular.module("Common").factory("historyFactory", function (jsonValue, $location, $rootScope, utils) { var historyStack = []; + var exceptViews = [jsonValue.views.analyticsSkill, jsonValue.views.signIn]; $rootScope.$on('$routeChangeSuccess', function (event, next, current) { - switch (utils.getView()) { - case jsonValue.views.analyticsSkill://dont need to keep track this url - case jsonValue.views.signIn://dont need to keep track this url - break; - + var view = utils.getView(); + switch (view) { case jsonValue.views.bubbleChart: case jsonValue.views.pieChart: // TODO: #1 - change the body background to black - $("body").css("background-color", "#201d1e") + $("body").css("background-color", "#201d1e"); default: instance.trackHistory(); @@ -28,7 +26,9 @@ angular.module("Common").factory("historyFactory", function (jsonValue, $locatio }, popHistory: function () { - historyStack.pop(); // remove current item + console.log(historyStack); + var url; // remove current item + do {url = historyStack.pop()} while(historyStack.indexOf(url) >= 0) if (historyStack.length === 0) return "/"; return historyStack.pop(); } From f7ab33ee214d1c0e0d1dbb82860ae23d21d93b36 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Fri, 9 Jan 2015 09:11:57 +0700 Subject: [PATCH 04/14] Fix History issue --- src/main/resources/local/logback.groovy | 5 ++-- .../assets/modules/common/history.fac.js | 28 +++++++++++-------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/main/resources/local/logback.groovy b/src/main/resources/local/logback.groovy index ce593c1ee..9e62bb361 100644 --- a/src/main/resources/local/logback.groovy +++ b/src/main/resources/local/logback.groovy @@ -13,9 +13,8 @@ appender("CONSOLE", ConsoleAppender) { } logger("org.springframework", DEBUG, ["CONSOLE"]) -logger("com.couchbase", ERROR, ["CONSOLE"]) -logger("net.spy.memcached", ERROR, ["CONSOLE"]) -logger("org.springframework.data.redis", ERROR, ["CONSOLE"]) +logger("org.springframework.data", ERROR, ["CONSOLE"]) +logger(" org.springframework.messaging", ERROR, ["CONSOLE"]) logger("org.springframework.session", ERROR, ["CONSOLE"]) root(ERROR, ["CONSOLE"]) \ No newline at end of file diff --git a/src/main/webapp/assets/modules/common/history.fac.js b/src/main/webapp/assets/modules/common/history.fac.js index b86245611..ef6baa9c2 100644 --- a/src/main/webapp/assets/modules/common/history.fac.js +++ b/src/main/webapp/assets/modules/common/history.fac.js @@ -1,16 +1,13 @@ angular.module("Common").factory("historyFactory", function (jsonValue, $location, $rootScope, utils) { var historyStack = []; - var exceptViews = [jsonValue.views.analyticsSkill, jsonValue.views.signIn]; + //var exceptViews = [jsonValue.views.analyticsSkill, jsonValue.views.signIn]; $rootScope.$on('$routeChangeSuccess', function (event, next, current) { - var view = utils.getView(); - switch (view) { + switch (utils.getView()) { case jsonValue.views.bubbleChart: case jsonValue.views.pieChart: // TODO: #1 - change the body background to black $("body").css("background-color", "#201d1e"); - - default: instance.trackHistory(); } @@ -21,16 +18,23 @@ angular.module("Common").factory("historyFactory", function (jsonValue, $locatio initialize: function () {}, trackHistory: function () { - while (historyStack.indexOf($location.path()) >= 0) {historyStack.pop();} - historyStack.push($location.path()); + var path = $location.path(); + while (historyStack.indexOf(path) >= 0) {historyStack.pop();} + historyStack.push(path); }, popHistory: function () { - console.log(historyStack); - var url; // remove current item - do {url = historyStack.pop()} while(historyStack.indexOf(url) >= 0) - if (historyStack.length === 0) return "/"; - return historyStack.pop(); + //var url; // remove current item + //do {url = historyStack.pop()} while(exceptViews.indexOf(url) >= 0); + //if (historyStack.length === 0) return "/"; + //return historyStack.pop(); + switch (utils.getView()) { + case jsonValue.views.jobsSearchText: + return jsonValue.routerUris.jobsSearch; + + default: + return historyStack.length > 0 ? historyStack.pop() : "/"; + } } } return instance; From f18c77b1d2671135de0b84c444275d633fa486ec Mon Sep 17 00:00:00 2001 From: Phuong H Date: Fri, 9 Jan 2015 09:48:16 +0700 Subject: [PATCH 05/14] Add new exception to support user not found --- .../techlooper/exception/EntityNotFoundException.java | 11 +++++++++++ .../service/impl/AbstractSocialService.java | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/techlooper/exception/EntityNotFoundException.java diff --git a/src/main/java/com/techlooper/exception/EntityNotFoundException.java b/src/main/java/com/techlooper/exception/EntityNotFoundException.java new file mode 100644 index 000000000..6c5d1e9f8 --- /dev/null +++ b/src/main/java/com/techlooper/exception/EntityNotFoundException.java @@ -0,0 +1,11 @@ +package com.techlooper.exception; + +/** + * Created by phuonghqh on 1/9/15. + */ +public class EntityNotFoundException extends Error { + + public EntityNotFoundException(String msg) { + super(msg); + } +} diff --git a/src/main/java/com/techlooper/service/impl/AbstractSocialService.java b/src/main/java/com/techlooper/service/impl/AbstractSocialService.java index 24311cc3c..4e1639943 100644 --- a/src/main/java/com/techlooper/service/impl/AbstractSocialService.java +++ b/src/main/java/com/techlooper/service/impl/AbstractSocialService.java @@ -2,6 +2,7 @@ import com.techlooper.entity.UserEntity; import com.techlooper.entity.UserProfile; +import com.techlooper.exception.EntityNotFoundException; import com.techlooper.model.SocialConfig; import com.techlooper.model.SocialProvider; import com.techlooper.repository.JsonConfigRepository; @@ -78,7 +79,7 @@ public OAuth1ConnectionFactory getOAuth1ConnectionFactory() { public UserEntity saveFootprint(com.techlooper.entity.AccessGrant accessGrant, String key) { UserEntity entity = userService.findUserEntityByKey(key); if (!Optional.ofNullable(entity).isPresent()) { - throw new UnsupportedOperationException("Method is not supported"); + throw new EntityNotFoundException("Can not find User by key: " + key); } userEntity(entity).withProfile(socialConfig.getProvider(), getProfile(accessGrant)); userService.save(entity); From cfa546f7476b821fe5e9d2049cefba04230c451d Mon Sep 17 00:00:00 2001 From: Phuong H Date: Fri, 9 Jan 2015 09:53:49 +0700 Subject: [PATCH 06/14] Remove redundant param --- .../com/techlooper/controller/UserController.java | 13 +++++-------- .../java/com/techlooper/model/SocialRequest.java | 1 - .../webapp/assets/modules/common/connection.fac.js | 3 +-- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/techlooper/controller/UserController.java b/src/main/java/com/techlooper/controller/UserController.java index 97a75efc7..988138a09 100644 --- a/src/main/java/com/techlooper/controller/UserController.java +++ b/src/main/java/com/techlooper/controller/UserController.java @@ -9,10 +9,7 @@ import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.validation.FieldError; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; @@ -49,16 +46,16 @@ public List save(@RequestBody @Valid UserInfo userInfo, BindingResul @MessageMapping("/user/findByKey") @ResponseBody @RequestMapping(value = "/user/findByKey", method = RequestMethod.POST) - public UserInfo getUserInfo(@RequestBody @Valid SocialRequest searchRequest/*, @DestinationVariable String username */) { - UserInfo userInfo = userService.findUserInfoByKey(searchRequest.getKey()); + public UserInfo getUserInfo(@CookieValue("techlooper.key") String techlooperKey/*, @DestinationVariable String username */) { + UserInfo userInfo = userService.findUserInfoByKey(techlooperKey); userInfo.getLoginSource(); return userInfo; } @ResponseBody @RequestMapping(value = "/user/verifyUserLogin", method = RequestMethod.POST) - public void verifyUserLogin(@RequestBody @Valid SocialRequest searchRequest, HttpServletResponse httpServletResponse) { - if (!textEncryptor.decrypt(searchRequest.getKey()).equals(searchRequest.getEmailAddress())) { + public void verifyUserLogin(@RequestBody SocialRequest searchRequest, @CookieValue("techlooper.key") String techlooperKey, HttpServletResponse httpServletResponse) { + if (!textEncryptor.encrypt(searchRequest.getEmailAddress()).equals(techlooperKey)) { httpServletResponse.setStatus(HttpServletResponse.SC_FORBIDDEN); } } diff --git a/src/main/java/com/techlooper/model/SocialRequest.java b/src/main/java/com/techlooper/model/SocialRequest.java index c312cd559..83dcd1da2 100644 --- a/src/main/java/com/techlooper/model/SocialRequest.java +++ b/src/main/java/com/techlooper/model/SocialRequest.java @@ -7,7 +7,6 @@ */ public class SocialRequest { - @NotNull private String key; private String emailAddress; diff --git a/src/main/webapp/assets/modules/common/connection.fac.js b/src/main/webapp/assets/modules/common/connection.fac.js index 8424eb1c2..4e82f25a6 100644 --- a/src/main/webapp/assets/modules/common/connection.fac.js +++ b/src/main/webapp/assets/modules/common/connection.fac.js @@ -68,7 +68,6 @@ angular.module("Common").factory("connectionFactory", var instance = { verifyUserLogin: function() { return $$.post(jsonValue.httpUri.verifyUserLogin, { - key: localStorageService.cookie.get(jsonValue.storage.key), emailAddress: $rootScope.userInfo !== undefined ? $rootScope.userInfo.emailAddress : "" }); }, @@ -96,7 +95,7 @@ angular.module("Common").factory("connectionFactory", findUserInfoByKey: function () { //HTTP version - $$.post(jsonValue.httpUri.getUserInfoByKey, {key: localStorageService.cookie.get(jsonValue.storage.key)}) + $$.post(jsonValue.httpUri.getUserInfoByKey) .then(function(userInfo) { $rootScope.userInfo = userInfo; utils.sendNotification(jsonValue.notifications.userInfo, userInfo); From 75085b7ef48e69c3d1b8fb79b56fa5b3debe54e8 Mon Sep 17 00:00:00 2001 From: Phuong H Date: Fri, 9 Jan 2015 11:43:01 +0700 Subject: [PATCH 07/14] Support vietnamese language --- .../assets/modules/bubble-chart/bubble-chart.fac.js | 2 +- src/main/webapp/assets/modules/job/searchBox.ser.js | 2 +- .../assets/modules/navigation/navigation.tem.html | 8 ++++---- .../webapp/assets/modules/pie-chart/pie-chart.fac.js | 2 +- .../webapp/assets/modules/register/register.ser.js | 6 +++++- .../webapp/assets/modules/register/register.tem.html | 12 ++++++------ src/main/webapp/assets/modules/signin/signin.ser.js | 2 +- .../modules/skill-analytics/skill-analytics.ser.js | 2 +- .../assets/modules/skill-circle/skill-circle.fac.js | 4 ---- .../assets/modules/translation/messages_en.json | 12 +++++++++++- .../assets/modules/translation/messages_vi.json | 12 +++++++++++- 11 files changed, 42 insertions(+), 22 deletions(-) diff --git a/src/main/webapp/assets/modules/bubble-chart/bubble-chart.fac.js b/src/main/webapp/assets/modules/bubble-chart/bubble-chart.fac.js index b18486399..c70d2cd13 100644 --- a/src/main/webapp/assets/modules/bubble-chart/bubble-chart.fac.js +++ b/src/main/webapp/assets/modules/bubble-chart/bubble-chart.fac.js @@ -244,7 +244,7 @@ angular.module('Bubble').factory('bubbleFactory', function (utils, jsonValue, $l }, enableNotifications: function () { - return $(".bubble-chart-container").is(":visible"); + return utils.getView() === jsonValue.views.bubbleChart; }, changeLang: function () { diff --git a/src/main/webapp/assets/modules/job/searchBox.ser.js b/src/main/webapp/assets/modules/job/searchBox.ser.js index 9daa24767..51047906a 100644 --- a/src/main/webapp/assets/modules/job/searchBox.ser.js +++ b/src/main/webapp/assets/modules/job/searchBox.ser.js @@ -30,7 +30,7 @@ angular.module("Jobs").factory("searchBoxService", function ($location, jsonValu }, enableNotifications: function () { - return $('.searchText').is(":visible"); + return [jsonValue.views.jobsSearch, jsonValue.views.jobsSearchText].indexOf(utils.getView()) >= 0; }, initializeSearchTextbox: function ($scope, $textArray) { diff --git a/src/main/webapp/assets/modules/navigation/navigation.tem.html b/src/main/webapp/assets/modules/navigation/navigation.tem.html index 31d3aae68..c8e0f5cf0 100644 --- a/src/main/webapp/assets/modules/navigation/navigation.tem.html +++ b/src/main/webapp/assets/modules/navigation/navigation.tem.html @@ -6,17 +6,17 @@ diff --git a/src/main/webapp/assets/modules/pie-chart/pie-chart.fac.js b/src/main/webapp/assets/modules/pie-chart/pie-chart.fac.js index f19d995ee..72be0197c 100644 --- a/src/main/webapp/assets/modules/pie-chart/pie-chart.fac.js +++ b/src/main/webapp/assets/modules/pie-chart/pie-chart.fac.js @@ -7,7 +7,7 @@ angular.module('Pie').factory('pieFactory', function (utils, jsonValue, termServ var $$ = { enableNotifications: function () { - return $(".pie-Chart-Container").is(":visible"); + return utils.getView() === jsonValue.views.pieChart; }, generateChartData: function ($terms) { diff --git a/src/main/webapp/assets/modules/register/register.ser.js b/src/main/webapp/assets/modules/register/register.ser.js index 314df0a44..cc81d2757 100644 --- a/src/main/webapp/assets/modules/register/register.ser.js +++ b/src/main/webapp/assets/modules/register/register.ser.js @@ -46,6 +46,10 @@ angular.module('Register').factory('registerService', enableNotifications: function () { return utils.getView() === jsonValue.views.register; + }, + + notUserInfo: function() { + localStorageService.set(jsonValue.storage.back2Me, "true"); } } @@ -77,7 +81,7 @@ angular.module('Register').factory('registerService', } }; - utils.registerNotification(jsonValue.notifications.notUserInfo, function () {localStorageService.set(jsonValue.storage.back2Me, "true");}, $$.enableNotifications); + utils.registerNotification(jsonValue.notifications.notUserInfo, $$.notUserInfo, $$.enableNotifications); utils.registerNotification(jsonValue.notifications.switchScope, $$.initialize, $$.enableNotifications); return instance; }); \ No newline at end of file diff --git a/src/main/webapp/assets/modules/register/register.tem.html b/src/main/webapp/assets/modules/register/register.tem.html index 34c832a56..9cc55b614 100644 --- a/src/main/webapp/assets/modules/register/register.tem.html +++ b/src/main/webapp/assets/modules/register/register.tem.html @@ -14,24 +14,24 @@

tagLine

-

Confirm Information

+

{{ 'confirmInformation' | translate }}

- +
- +
+ disabled="disabled">
-

Choose Your salary:

+

{{ 'chooseYourSalary' | translate }} :