server/api: refactor + remove ID from user JSON

This commit is contained in:
rr-
2016-04-16 15:07:33 +02:00
parent adecdd4cd9
commit e4239a199c
23 changed files with 482 additions and 560 deletions

View File

@ -155,7 +155,7 @@ class UsersController {
files.avatar = data.avatarContent;
}
const isLoggedIn = api.isLoggedIn() && api.user.id == user.id;
const isLoggedIn = api.isLoggedIn(user);
return new Promise((resolve, reject) => {
api.put('/user/' + user.name, data, files)
.then(response => {
@ -182,7 +182,7 @@ class UsersController {
}
_delete(user) {
const isLoggedIn = api.isLoggedIn() && api.user.id == user.id;
const isLoggedIn = api.isLoggedIn(user);
return new Promise((resolve, reject) => {
api.delete('/user/' + user.name)
.then(response => {
@ -205,7 +205,7 @@ class UsersController {
}
_show(user, section) {
const isLoggedIn = api.isLoggedIn() && api.user.id == user.id;
const isLoggedIn = api.isLoggedIn(user);
const infix = isLoggedIn ? 'self' : 'any';
const myRankIdx = api.user ? config.ranks.indexOf(api.user.rank) : 0;