Compare commits

..

No commits in common. "9fc6950664529548e5aed51e3276ed0b7b3606be" and "06a97858d9b5abee15bb0cf7bbc559ef7a2e183d" have entirely different histories.

3 changed files with 3 additions and 42 deletions

View File

@ -8,12 +8,7 @@ class UsersEndpoint extends ApiEndpoint {
path: '/users' path: '/users'
}); });
this.methods.push([ 'get', this.getUsers.bind(this) ]); this.methods.push([ 'get', this.getUsers.bind(this), [ server.auth.createAuthoriser('administrator', 10) ]]);
this.subpaths = [
[ '/:userid', 'get', this.user.bind(this) ],
[ '/:userid/applications', 'get', this.userApplications.bind(this) ]
];
this.middleware = [ server.auth.createAuthoriser('administrator', 10) ];
} }
@ -25,23 +20,6 @@ class UsersEndpoint extends ApiEndpoint {
res.json(users.map(user => user.json)); res.json(users.map(user => user.json));
} }
async user (req, res) {
const { params } = req;
const { userid } = params;
const user = await this.server.users.fetchUser(userid);
if (!user) return res.status(404).end();
res.json(user);
}
async userApplications (req, res) {
const { params } = req;
const { userid } = params;
const user = await this.server.users.fetchUser(userid);
if (!user) return res.status(404).send('Could not find the user');
const applications = await user.fetchApplications();
res.json(Object.values(applications).map(app => app.json));
}
} }
module.exports = UsersEndpoint; module.exports = UsersEndpoint;

View File

@ -87,9 +87,7 @@ class Authenticator {
const bool = user?._2fa && !sess.verified && sess.loginMethod === 'password'; const bool = user?._2fa && !sess.verified && sess.loginMethod === 'password';
const verifyPath = '/login/verify'; const verifyPath = '/login/verify';
// TODO: clean this up // TODO: clean this up
if (bool && ![ verifyPath, '/api' + verifyPath ].includes(req.originalUrl)) { if (bool && ![ verifyPath, '/api' + verifyPath ].includes(req.originalUrl)) return res.redirect(verifyPath);
return res.status(401).json({ twoFactor: true }); // res.redirect(verifyPath);
}
next(); next();
} }

View File

@ -5,22 +5,7 @@ const UserApplicataion = require('./UserApplication');
class User { class User {
static defaultPermissions = { static defaultPermissions = {};
developer: {
default: 0
},
administrator: {
default: 0
},
test: {
default: 0,
dingus: {
bingus: {
default: 10
}
}
}
};
static validTypes = []; static validTypes = [];