Skip to content

Commit 7018566

Browse files
committed
bit of cleanup and documentation
1 parent 6352c8f commit 7018566

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

src/main/java/net/developerden/backend/controller/InfoController.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import net.developerden.backend.security.DiscordUser;
44
import org.springframework.security.core.annotation.AuthenticationPrincipal;
5-
import org.springframework.security.oauth2.core.user.OAuth2User;
65
import org.springframework.web.bind.annotation.GetMapping;
76
import org.springframework.web.bind.annotation.RestController;
87

@@ -11,6 +10,6 @@ public class InfoController {
1110

1211
@GetMapping("/user")
1312
public String user(@AuthenticationPrincipal DiscordUser principal) {
14-
return "Hello, " + principal.getName();
13+
return "Hello, %s (%s)".formatted(principal.fullName(), principal.id());
1514
}
1615
}

src/main/java/net/developerden/backend/security/DiscordUser.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,13 @@
66
import java.util.Collection;
77
import java.util.Map;
88

9+
/* TODO we might wanna convert this to a database entity in the future so we can add more data*/
10+
11+
/**
12+
* Java representation of all of the data that Discord gives us from the /users/@me API endpoint.
13+
*/
914
public record DiscordUser(String id, String username, String discriminator, String locale) implements OAuth2User {
10-
private String fullName() {
15+
public String fullName() {
1116
return username + "#" + discriminator;
1217
}
1318

0 commit comments

Comments
 (0)