mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-06-04 00:44:41 +08:00
Added options to allow whole site to be made public. Fixes #3.
This commit is contained in:
@ -4,6 +4,7 @@ namespace Oxbow\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Setting;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
@ -33,7 +34,8 @@ class Authenticate
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
$sitePublic = Setting::get('app-public', false) === 'true';
|
||||
if ($this->auth->guest() && !$sitePublic) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
|
@ -68,6 +68,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
*/
|
||||
public function can($permissionName)
|
||||
{
|
||||
if($this->email == 'guest') {
|
||||
return false;
|
||||
}
|
||||
$permissions = $this->role->permissions()->get();
|
||||
$permissionSearch = $permissions->search(function ($item, $key) use ($permissionName) {
|
||||
return $item->name == $permissionName;
|
||||
|
Reference in New Issue
Block a user