mirror of
https://github.com/psforever/PSFPortal.git
synced 2026-04-20 20:05:18 +00:00
Enable foreign profile view
This commit is contained in:
parent
20946fdb43
commit
cb918033a6
14 changed files with 248 additions and 125 deletions
17
api/user.js
17
api/user.js
|
|
@ -16,10 +16,17 @@ api.get('/user', async (req, res, next) => {
|
|||
}
|
||||
});
|
||||
|
||||
api.get('/user/profile', async (req, res, next) => {
|
||||
api.get('/user/:user/profile', async (req, res, next) => {
|
||||
const target_account = req.user;
|
||||
|
||||
if (target_account.id !== req.session.account_id && !req.session_account.gm) {
|
||||
res.status(403).json({ message: 'not allowed to see for other users' });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const account = await db.get_account_by_id(req.session.account_id);
|
||||
const characters = await db.get_characters_by_account(req.session.account_id);
|
||||
const account = await db.get_account_by_id(target_account.id);
|
||||
const characters = await db.get_characters_by_account(target_account.id);
|
||||
|
||||
res.status(200).json({
|
||||
id : account.id,
|
||||
|
|
@ -36,19 +43,17 @@ api.get('/user/profile', async (req, res, next) => {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
api.get('/user/:user/logins', async (req, res, next) => {
|
||||
const account = req.user;
|
||||
const pagination = get_pagination(req);
|
||||
|
||||
if (account.id !== req.session.account_id) {
|
||||
if (account.id !== req.session.account_id && !req.session_account.gm) {
|
||||
res.status(403).json({ message: 'not allowed to see for other users' });
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
const logins = await db.get_account_logins(account.id, pagination)
|
||||
console.log(logins)
|
||||
res.status(200).json({ logins : logins, page: pagination});
|
||||
} catch (e) {
|
||||
console.log(e)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue