mirror of
https://github.com/ArthurDanjou/artdanj-shortener.git
synced 2026-01-22 13:51:32 +01:00
Show clicks only if user is authenticated
This commit is contained in:
@@ -55,14 +55,24 @@ export default class LinksController {
|
||||
}
|
||||
}
|
||||
|
||||
public async index ({ response }: HttpContextContract) {
|
||||
const links = await Link
|
||||
.query()
|
||||
.orderBy('id', 'asc')
|
||||
.preload('author', (query) => {
|
||||
query.select('email')
|
||||
})
|
||||
.preload('clicks')
|
||||
public async index ({ response, auth }: HttpContextContract) {
|
||||
let links: Link[]
|
||||
if (auth.isAuthenticated && auth.isLoggedIn) {
|
||||
links = await Link
|
||||
.query()
|
||||
.orderBy('id', 'asc')
|
||||
.preload('author', (query) => {
|
||||
query.select('email')
|
||||
})
|
||||
.preload('clicks')
|
||||
} else {
|
||||
links = await Link
|
||||
.query()
|
||||
.orderBy('id', 'asc')
|
||||
.preload('author', (query) => {
|
||||
query.select('email')
|
||||
})
|
||||
}
|
||||
return response.status(200).send({
|
||||
links
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user