Skip to content

Commit

Permalink
Merge pull request #37 from Kovah/dev
Browse files Browse the repository at this point in the history
v0.0.8
  • Loading branch information
Kovah authored Mar 1, 2019
2 parents d4a4aa3 + e9ca3d7 commit 63216c2
Show file tree
Hide file tree
Showing 30 changed files with 171 additions and 235 deletions.
6 changes: 0 additions & 6 deletions .env.docker
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ APP_KEY=
# Enable the debug more if you are running into issues or while developing
APP_DEBUG=true

## LinkAce settings
# The page title configures the content of the <title></title> element
PAGE_TITLE=''
# If set to true, guests can access your public bookmarks and notes
GUEST_ACCESS=false

## Configuration of the database connection
# Set the database driver (mysql, )
DB_CONNECTION=mysql
Expand Down
6 changes: 0 additions & 6 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ APP_KEY=
# Enable the debug more if you are running into issues or while developing
APP_DEBUG=true

## LinkAce settings
# The page title configures the content of the <title></title> element
PAGE_TITLE=''
# If set to true, guests can access your public bookmarks and notes
GUEST_ACCESS=false

## Configuration of the database connection
# Set the database driver (mysql, )
DB_CONNECTION=mysql
Expand Down
9 changes: 0 additions & 9 deletions app/Console/RegisterUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ class RegisterUserCommand extends Command
*/
protected $description = 'Register a new user';

private $user_roles = [
'admin',
'user',
];

/**
* RegisterUser constructor.
*/
Expand Down Expand Up @@ -69,16 +64,12 @@ public function handle()

$password = $this->secret('Please enter a password for ' . $name);

$role = $this->choice('Please choose the user role:', $this->user_roles, 'user');

$new_user = User::create([
'name' => $name,
'email' => $email,
'password' => Hash::make($password),
]);

$new_user->assignRole($role);

$this->info('User ' . $name . ' registered.');
return;
}
Expand Down
32 changes: 23 additions & 9 deletions app/Http/Controllers/App/SystemSettingsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,37 @@ class SystemSettingsController extends Controller
*/
public function getSystemSettings()
{
if (!auth()->user()->hasRole('admin')) {
abort(403);
}

return view('actions.settings.system');
}

/**
* Syve the new system settings to the database
*
* @param Request $request
* @return \Illuminate\Http\RedirectResponse
*/
public function saveSystemSettings(Request $request)
{
//
$request->validate([
'system_guest_access' => 'numeric',
]);

$settings = $request->except(['_token']);

foreach ($settings as $key => $value) {
Setting::updateOrCreate([
'key' => $key,
'user_id' => null,
], [
'key' => $key,
'value' => $value,
'user_id' => null,
]);
}

alert(trans('settings.settings_saved'));

return redirect()->back();
}

/**
Expand All @@ -42,10 +60,6 @@ public function saveSystemSettings(Request $request)
*/
public function generateCronToken(Request $request)
{
if (!auth()->user()->hasRole('admin')) {
abort(403);
}

$new_token = Str::random(32);

Setting::updateOrCreate(
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/FrontController.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class FrontController extends Controller
public function index()
{
if (!auth()->check()) {
if (env('GUEST_ACCESS', false)) {
if (systemsettings('system_guest_access')) {
return redirect()->route('guest.links.index');
}

Expand Down
26 changes: 0 additions & 26 deletions app/Http/Controllers/Guest/CategoryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,6 @@

class CategoryController extends Controller
{
/**
* Display a listing of the resource.
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
$categories = Category::parentOnly();

if ($request->has('orderBy') && $request->has('orderDir')) {
$categories->orderBy($request->get('orderBy'), $request->get('orderDir'));
} else {
$categories->orderBy('name', 'ASC');
}

$categories = $categories->paginate(getPaginationLimit());

return view('guest.categories.index', [
'categories' => $categories,
'route' => $request->fullUrl(),
'order_by' => $request->get('orderBy'),
'order_dir' => $request->get('orderDir'),
]);
}

/**
* Display the specified resource.
*
Expand Down
24 changes: 0 additions & 24 deletions app/Http/Controllers/Guest/TagController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,6 @@

class TagController extends Controller
{
/**
* Display a listing of the resource.
*
* @param Request $request
* @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
*/
public function index(Request $request)
{
if ($request->has('orderBy') && $request->has('orderDir')) {
$tags = Tag::orderBy($request->get('orderBy'), $request->get('orderDir'));
} else {
$tags = Tag::orderBy('name', 'ASC');
}

$tags = $tags->paginate(getPaginationLimit());

return view('guest.tags.index', [
'tags' => $tags,
'route' => $request->fullUrl(),
'order_by' => $request->get('orderBy'),
'order_dir' => $request->get('orderDir'),
]);
}

/**
* Display the specified resource.
*
Expand Down
1 change: 1 addition & 0 deletions app/Http/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ class Kernel extends HttpKernel
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'guestaccess' => \App\Http\Middleware\GuestAccess::class,
'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
Expand Down
30 changes: 30 additions & 0 deletions app/Http/Middleware/GuestAccess.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace App\Http\Middleware;

use Closure;

class GuestAccess
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
// Check for logged in users
if (auth()->check()) {
return redirect()->route('dashboard');
}

// Check if guest access is enabled
if (systemsettings('system_guest_access') === '1') {
return $next($request);
}

return redirect()->route('login');
}
}
2 changes: 0 additions & 2 deletions app/Models/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
use Spatie\Permission\Traits\HasRoles;

/**
* Class User
Expand All @@ -21,7 +20,6 @@
class User extends Authenticatable
{
use Notifiable;
use HasRoles;

/**
* The attributes that are mass assignable.
Expand Down
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A small, selfhosted bookmark manager with advanced features, built with Laravel and Docker",
"license": "MIT",
"type": "project",
"version": "0.0.7",
"version": "0.0.8",
"require": {
"php": "^7.1.3",
"doctrine/dbal": "^2.8",
Expand All @@ -12,7 +12,6 @@
"laravel/tinker": "^1.0",
"predis/predis": "^1.1",
"shaarli/netscape-bookmark-parser": "^2.1",
"spatie/laravel-permission": "^2.31",
"vinkla/alert": "^3.0.0",
"watson/rememberable": "^2.0"
},
Expand Down
68 changes: 2 additions & 66 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linkace",
"version": "0.0.7",
"version": "0.0.8",
"description": "A small, selfhosted bookmark manager with advanced features, built with Laravel and Docker",
"homepage": "https://github.com/Kovah/LinkAce",
"repository": {
Expand Down
4 changes: 4 additions & 0 deletions resources/lang/en/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@
'api_token_generate_info' => 'Caution: If you already have an API token, generating a new one will break all existing integrations!',
'api_token_generate_failure' => 'A new API token could not be generated. Please check your browser console and application logs for more information.',

'sys_page_title' => 'Page Title',
'sys_guest_access' => 'Enable Guest Access',
'sys_guest_access_help' => 'If enabled, guest will be able to see all links that are not private.',

'cron_token' => 'Cron Token',
'cron_token_generate' => 'Generate Token',
'cron_token_generate_confirm' => 'Do you really want to generate a new token?',
Expand Down
Loading

0 comments on commit 63216c2

Please sign in to comment.