|
|
|
@ -220,6 +220,28 @@ class AuthController extends Controller {
|
|
|
|
|
return res.api(await user.to_api())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async get_user_photo(req, res, next) {
|
|
|
|
|
let user
|
|
|
|
|
if ( req.params.id === 'me' ) {
|
|
|
|
|
user = req.user
|
|
|
|
|
} else {
|
|
|
|
|
const User = this.models.get('auth:User')
|
|
|
|
|
user = await User.findOne({ uid: req.params.id })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !user )
|
|
|
|
|
return res.status(404)
|
|
|
|
|
.message(req.T('api.user_not_found'))
|
|
|
|
|
.api()
|
|
|
|
|
|
|
|
|
|
const file = await user.photo()
|
|
|
|
|
if ( !file )
|
|
|
|
|
// The user does not have a profile. Send the default.
|
|
|
|
|
return res.sendFile(this.utility.path('app/assets/people.png'))
|
|
|
|
|
|
|
|
|
|
await file.send(res)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async create_group(req, res, next) {
|
|
|
|
|
if ( !req.user.can(`auth:group:create`) )
|
|
|
|
|
return res.status(401)
|
|
|
|
|