Skip to content

Commit

Permalink
Fix facebook login
Browse files Browse the repository at this point in the history
  • Loading branch information
phuonghuynh committed Jan 9, 2015
1 parent 581009b commit 806ef64
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/com/techlooper/config/CoreConfiguration.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ protected void configure() {
.fields("accountEmail", "emailAddress", FieldsMappingOptions.copyByReference())
.fields("imageUrl", "profileImageUrl", FieldsMappingOptions.copyByReference());

mapping(FacebookProfile.class, com.techlooper.entity.UserEntity.class, TypeMappingOptions.oneWay())
mapping(com.techlooper.entity.FacebookProfile.class, com.techlooper.entity.UserEntity.class, TypeMappingOptions.oneWay())
.fields("email", "emailAddress", FieldsMappingOptions.copyByReference());

mapping(LinkedInProfile.class, com.techlooper.entity.UserEntity.class, TypeMappingOptions.oneWay())
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/techlooper/controller/SocialController.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,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(textEncryptor.encrypt(userEntity.getEmailAddress())).build();
.withKey(textEncryptor.encrypt(userEntity.key())).build();
}

@ResponseBody
Expand All @@ -72,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(textEncryptor.encrypt(userEntity.getEmailAddress())).build();
.withKey(textEncryptor.encrypt(userEntity.key())).build();
}
AccessGrant accessGrant = service.getAccessGrant(null, null);
httpServletResponse.sendRedirect(accessGrant.getAuthorizeUrl());
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/com/techlooper/entity/UserEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.techlooper.model.SocialProvider;
import org.springframework.data.annotation.Id;
import org.springframework.data.couchbase.core.mapping.Document;
import org.springframework.util.StringUtils;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -34,6 +35,10 @@ public class UserEntity {

private String profileImageUrl;

public String key() {
return StringUtils.hasText(emailAddress) ? emailAddress : id;
}

public String getProfileImageUrl() {
return profileImageUrl;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,6 @@ public class UserServiceImpl implements UserService {

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);
}

public void save(UserInfo userInfo) {
Expand Down

0 comments on commit 806ef64

Please sign in to comment.