Skip to content

Commit 4e7632b

Browse files
Upgraded to Spring Boot 2.2.0
1 parent 2560297 commit 4e7632b

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

lemon-demo-reactive/src/main/java/com/naturalprogrammer/spring/lemondemo/services/MyService.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
package com.naturalprogrammer.spring.lemondemo.services;
22

3+
import java.util.Map;
4+
35
import org.bson.types.ObjectId;
6+
import org.springframework.security.oauth2.core.oidc.StandardClaimNames;
47
import org.springframework.stereotype.Service;
58

69
import com.naturalprogrammer.spring.lemon.commons.security.UserDto;
@@ -32,6 +35,28 @@ protected void updateUserFields(User user, User updatedUser, UserDto currentUser
3235
user.setName(updatedUser.getName());
3336
}
3437

38+
@Override
39+
public void fillAdditionalFields(String registrationId, User user, Map<String, Object> attributes) {
40+
41+
String nameKey;
42+
43+
switch (registrationId) {
44+
45+
case "facebook":
46+
nameKey = StandardClaimNames.NAME;
47+
break;
48+
49+
case "google":
50+
nameKey = StandardClaimNames.NAME;
51+
break;
52+
53+
default:
54+
throw new UnsupportedOperationException("Fetching name from " + registrationId + " login not supprrted");
55+
}
56+
57+
user.setName((String) attributes.get(nameKey));
58+
}
59+
3560
@Override
3661
protected ObjectId toId(String id) {
3762
return new ObjectId(id);

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<parent>
1616
<groupId>org.springframework.boot</groupId>
1717
<artifactId>spring-boot-starter-parent</artifactId>
18-
<version>2.2.0.BUILD-SNAPSHOT</version>
18+
<version>2.2.0.RELEASE</version>
1919
<relativePath /> <!-- lookup parent from repository -->
2020
</parent>
2121

0 commit comments

Comments
 (0)