- added working typescript support to vue
- added bouncer support - added UserPolicies - added first user index call
This commit is contained in:
@@ -1,14 +1,17 @@
|
||||
import type { HttpContextContract } from '@ioc:Adonis/Core/HttpContext'
|
||||
import User from 'App/Models/User'
|
||||
import Logger from '@ioc:Adonis/Core/Logger'
|
||||
import Database from '@ioc:Adonis/Lucid/Database'
|
||||
|
||||
export default class UsersController {
|
||||
public async index({ auth, response, inertia }: HttpContextContract) {
|
||||
public async index({ inertia, bouncer }: HttpContextContract) {
|
||||
|
||||
if(auth.user?.isAdmin) {
|
||||
return inertia.render('Users/Index')
|
||||
}
|
||||
else response.redirect().toRoute('events.index')
|
||||
await bouncer.with('UserPolicy').authorize('index')
|
||||
|
||||
const users = await Database
|
||||
.from('users')
|
||||
.select('id', 'username', 'is_admin')
|
||||
|
||||
return inertia.render('Users/Index', { users })
|
||||
}
|
||||
|
||||
public async create({ auth, inertia }: HttpContextContract) {
|
||||
|
||||
Reference in New Issue
Block a user