Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed error checking when submitting no user, admin can remove themself #223

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions laravel/app/Http/Controllers/SlotController.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,12 @@ public function adminRelease(Request $request, Slot $slot)
}

public function adminAssign(Request $request, Slot $slot)
{
$user = User::findorFail($request->get('user'));
{
$user = User::find($request->get('user'));
if (empty($user)) {
$request->session()->flash('error', 'You didn\'t select a user to add.');
return redirect()->back();
}

if(is_null($slot->user))
{
Expand Down
3 changes: 2 additions & 1 deletion laravel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
"webpack-cli": "^4.0.0"
},
"dependencies": {
"@babel/preset-env": "^7.16.11",
"bootstrap-sass": "^3.4.1",
"ejs-loader": "^0.5.0",
"estraverse": "^5.2.0",
"lodash": "^4.17.20",
"lodash": "^4.17.21",
"sass": "^1.27.0",
"socket.io-client": "^2.3.1",
"wetfish-basic": "^0.7.11"
Expand Down
7 changes: 6 additions & 1 deletion laravel/resources/views/pages/slot/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,17 @@
{
$self = true;
$url = "/slot/{$slot->id}/release";
//if the admin is trying to release themselves from a slot
if(Auth::user()->hasRole('admin') || Auth::user()->hasRole('department-lead'))
{
$url = "/slot/{$slot->id}/adminRelease";
}
}
else
{
$other = true;
}

//if the admin is trying to release someone else from their slot
if(Auth::check() && (Auth::user()->hasRole('admin') || Auth::user()->hasRole('department-lead')))
{
$adminUrl = "/slot/{$slot->id}/adminRelease";
Expand Down