Skip to content

Commit

Permalink
correcting user get for images
Browse files Browse the repository at this point in the history
  • Loading branch information
mathias committed Jan 9, 2024
1 parent 94b00ca commit 51a80cc
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions app/Controllers/Http/UserController.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
import User from 'App/Models/User'
import Drive from "@ioc:Adonis/Core/Drive";

export default class UserController {
public async index(HttpContextContract: HttpContextContract) {
let users = {}
if (HttpContextContract.auth.user) {
users = await User.query()
let users = await User.query()
.select('id', 'username', 'avatar_url')
.whereNot('id', HttpContextContract.auth.user.id)
for (let user of users) {
user.avatarUrl = await Drive.getSignedUrl(user.avatarUrl)
}
HttpContextContract.response.send(JSON.stringify(users))
}
HttpContextContract.response.send(JSON.stringify(users))
HttpContextContract.response.unauthorized()
}
}

0 comments on commit 51a80cc

Please sign in to comment.