Add flat user endpoint
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
159fdb15e6
commit
5420cf58bd
@ -220,6 +220,26 @@ class AuthController extends Controller {
|
|||||||
return res.api(await user.to_api())
|
return res.api(await user.to_api())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async get_user_flat(req, res, next) {
|
||||||
|
if ( req.params.id === 'me' )
|
||||||
|
return res.json(await req.user.to_api())
|
||||||
|
|
||||||
|
const User = this.models.get('auth:User')
|
||||||
|
const user = await User.findById(req.params.id)
|
||||||
|
|
||||||
|
if ( !user )
|
||||||
|
return res.status(404)
|
||||||
|
.message(req.T('api.user_not_found'))
|
||||||
|
.api()
|
||||||
|
|
||||||
|
if ( !req.user.can(`auth:user:${user.id}:view`) )
|
||||||
|
return res.status(401)
|
||||||
|
.message(req.T('api.insufficient_permissions'))
|
||||||
|
.api()
|
||||||
|
|
||||||
|
return res.json(await user.to_api())
|
||||||
|
}
|
||||||
|
|
||||||
async get_user_photo(req, res, next) {
|
async get_user_photo(req, res, next) {
|
||||||
let user
|
let user
|
||||||
if ( req.params.id === 'me' ) {
|
if ( req.params.id === 'me' ) {
|
||||||
|
@ -36,6 +36,11 @@ const auth_routes = {
|
|||||||
['middleware::api:Permission', { check: 'v1:auth:users:get' }],
|
['middleware::api:Permission', { check: 'v1:auth:users:get' }],
|
||||||
'controller::api:v1:Auth.get_user',
|
'controller::api:v1:Auth.get_user',
|
||||||
],
|
],
|
||||||
|
'/users/:id/flat': [
|
||||||
|
'middleware::auth:APIRoute',
|
||||||
|
['middleware::api:Permission', { check: 'v1:auth:users:get' }],
|
||||||
|
'controller::api:v1:Auth.get_user_flat',
|
||||||
|
],
|
||||||
'/users/:id/photo': [
|
'/users/:id/photo': [
|
||||||
'controller::api:v1:Auth.get_user_photo',
|
'controller::api:v1:Auth.get_user_photo',
|
||||||
],
|
],
|
||||||
|
Loading…
Reference in New Issue
Block a user