Permission fixes

This commit is contained in:
frederikpyt 2020-07-29 12:18:08 +02:00
parent faec1f66c5
commit a5cb2e2cde
3 changed files with 6 additions and 10 deletions

View File

@ -13,6 +13,9 @@ class RootController extends Controller
}
public function index() {
return Response::detect("root.index");
if(auth()->user()->can('admin.panel.show'))
return Response::detect("root.index");
else
return view('app.root.index');
}
}

View File

@ -60,29 +60,21 @@ class UserController extends Controller
*/
public function store(Request $request)
{
// Log::debug("STORE FUNCTION");
$data = $request->validate([
"name_first" => "required|max:255",
"name_last" => "required|max:255",
"email" => "required|email|unique:users",
"password" => "required|max:60",
"phone" => "required|unique:users",
]);
// Log::debug("FINISHED VALIDATION?");
$rolez = $request->input("roles", [ "User" ]);
$user = new User($data);
// Log::debug("CREATED USER [NOT PERSISTED YET]");
$user->assignRole($rolez);
$user->save();
// Log::debug("SAVED USER");
return Response::detect("users.store");
}

View File

@ -98,7 +98,8 @@ class PermissionSeeder extends Seeder
"washing.machine.reservation.edit" => "Allows editing of washing machine reservations",
"washing.machine.reservation.delete" => "Allows deletion of washing machine reservations",
//Allows access to the admin panel
"admin.panel.show" => "Allows access to administration panel",
];
foreach ($permissions as $key => $value) {