Browse Source

Update flash message for unauthorized access

pull/6/head
Nafies Luthfi 8 years ago
parent
commit
00e79b9b9c
  1. 4
      app/Exceptions/Handler.php
  2. 2
      app/Http/Middleware/Role.php
  3. 3
      resources/lang/en/auth.php
  4. 3
      resources/lang/id/auth.php
  5. 2
      tests/Feature/ManageProjectsTest.php

4
app/Exceptions/Handler.php

@ -54,7 +54,7 @@ class Handler extends ExceptionHandler
return response()->json(['error' => 'Forbidden Action.'], 403);
}
flash()->error('Invalid access');
flash(__('auth.unauthorized_access', ['url' => $request->path()]), 'danger');
return redirect()->home();
}
@ -64,7 +64,7 @@ class Handler extends ExceptionHandler
return response()->json(['error' => 'Data not found.'], 404);
}
flash()->error('Data not found.');
flash('Data not found.', 'danger');
return redirect()->home();
}

2
app/Http/Middleware/Role.php

@ -29,7 +29,7 @@ class Role
// Cek apakah grup user ada di dalam array $nameArray?
if (auth()->user()->hasRoles($nameArray) == false) {
flash()->error('Anda tidak dapat mengakses halaman '.$request->path().'.');
flash(__('auth.unauthorized_access', ['url' => $request->path()]), 'danger');
return redirect()->route('home');
}

3
resources/lang/en/auth.php

@ -36,4 +36,7 @@ return [
'old_password' => 'Old Password',
'new_password' => 'New Password',
'new_password_confirmation' => 'Confirm new Password',
// Authorization
'unauthorized_access' => 'You cannot access :url page.',
];

3
resources/lang/id/auth.php

@ -36,4 +36,7 @@ return [
'old_password' => 'Password Lama',
'new_password' => 'Password Baru',
'new_password_confirmation' => 'Ulangi Password Baru',
// Authorization
'unauthorized_access' => 'Anda tidak dapat mengakses halaman :url.',
];

2
tests/Feature/ManageProjectsTest.php

@ -164,7 +164,7 @@ class ManageProjectsTest extends TestCase
$this->press(trans('project.create'));
$this->seePageIs(route('projects.create'));
$this->see('Mohon periksa kembali form isian Anda.');
$this->see(__('validation.flash_message'));
}
/** @test */

Loading…
Cancel
Save