const ServerUser = require('../../../lib/db/user/User');

module.exports = async function (req, res, next) {

	try {
		const user = new ServerUser(req.user);
		const target = await ServerUser.fromSQL(null, req.params.user_id);

		if (requestor.canRead(target)) {
			res.status(200).send(target.toJSON());
		} else {
			throw {status: 403, message: "Access denied"};
		}
	} catch (err) {
		next(err);
	}

};
