aboutsummaryrefslogtreecommitdiff
path: root/juick-server/src/main
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2018-06-27 14:04:59 +0300
committerGravatar Vitaly Takmazov2018-06-27 14:04:59 +0300
commit0f0df74a6a0b069eabbf788d754389ee4c396f84 (patch)
treec25da351aec88eb5602ea35eb330376ae6d5a7d3 /juick-server/src/main
parentdd605a1731cdcdf02317bedf7d946605a21e0bd8 (diff)
move hash to /me endpoint
Diffstat (limited to 'juick-server/src/main')
-rw-r--r--juick-server/src/main/java/com/juick/server/api/Users.java20
1 files changed, 17 insertions, 3 deletions
diff --git a/juick-server/src/main/java/com/juick/server/api/Users.java b/juick-server/src/main/java/com/juick/server/api/Users.java
index 2783e9bc..4e447d04 100644
--- a/juick-server/src/main/java/com/juick/server/api/Users.java
+++ b/juick-server/src/main/java/com/juick/server/api/Users.java
@@ -61,14 +61,22 @@ public class Users {
if (!users.isEmpty())
return users;
if (!UserUtils.getCurrentUser().isAnonymous()) {
- com.juick.User visitor = UserUtils.getCurrentUser();
- visitor.setAuthHash(getAuthToken());
- return Collections.singletonList(visitor);
+ return Collections.singletonList(UserUtils.getCurrentUser());
}
throw new HttpNotFoundException();
}
+ @GetMapping("/me")
+ public SecureUser getMe() {
+ User visitor = UserUtils.getCurrentUser();
+ SecureUser me = new SecureUser();
+ me.setUid(visitor.getUid());
+ me.setName(visitor.getName());
+ me.setAuthHash(getAuthToken());
+ return me;
+ }
+
@RequestMapping(value = "/users/read", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public List<User> doGetUserRead(
@RequestParam String uname) {
@@ -124,4 +132,10 @@ public class Users {
}
throw new HttpNotFoundException();
}
+
+ class SecureUser extends User {
+ public String getHash() {
+ return getAuthHash();
+ }
+ }
}