Skip to content

Commit

Permalink
Updated Super Admin Modification Constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
4jean committed Jun 20, 2020
1 parent bfee6bf commit c71ed5b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/Helpers/Qs.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ public static function getStaff($remove=[])
return $remove ? array_values(array_diff($data, $remove)) : $data;
}

// Check if User is Head of Super Admins (Untouchable)
public static function headSA(int $user_id)
{
return $user_id === 1;
}

public static function userIsPTA()
{
return in_array(Auth::user()->user_type, self::getPTA());
Expand Down
11 changes: 11 additions & 0 deletions app/Http/Controllers/SupportTeam/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,12 @@ public function store(UserRequest $req)
public function update(UserRequest $req, $id)
{
$id = Qs::decodeHash($id);

// Redirect if Making Changes to Head of Super Admins
if(Qs::headSA($id)){
return Qs::json(__('msg.denied'), FALSE);
}

$user = $this->user->find($id);

$user_type = $user->user_type;
Expand Down Expand Up @@ -161,6 +167,11 @@ public function destroy($id)
{
$id = Qs::decodeHash($id);

// Redirect if Making Changes to Head of Super Admins
if(Qs::headSA($id)){
return Qs::json(__('msg.denied'), FALSE);
}

$user = $this->user->find($id);

if($user->user_type == 'teacher' && $this->userTeachesSubject($user)) {
Expand Down

0 comments on commit c71ed5b

Please sign in to comment.