User accounts can now be created using the new user management screen. Added cURL as a required PHP extension

This commit is contained in:
Andy Heathershaw 2016-10-01 15:24:22 +01:00
parent 8b4af87b15
commit 1b86fa1e0e
13 changed files with 300 additions and 21 deletions

View File

@ -3,7 +3,7 @@
<component name="WebServers">
<option name="servers">
<webServer id="b14a34b0-0127-4886-964a-7be75a2281ac" name="Development" url="http://blue-twilight-dev.andys.eu">
<fileTransfer host="orlando.andys.eu" port="22" rootFolder="/srv/www/blue-twilight-dev" accessType="SFTP">
<fileTransfer host="orlando.default.pandy06269.uk0.bigv.io" port="22" rootFolder="/srv/www/blue-twilight-dev" accessType="SFTP">
<advancedOptions>
<advancedOptions dataProtectionLevel="Private" />
</advancedOptions>

View File

@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Facade\Theme;
use App\Facade\UserConfig;
use App\User;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class UserController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$this->authorize('admin-access');
$users = User::orderBy('name')
->paginate(UserConfig::get('items_per_page'));
return Theme::render('admin.list_users', [
'users' => $users
]);
}
/**
* Show the form for creating a new resource.
*
* @return \Illuminate\Http\Response
*/
public function create()
{
$this->authorize('admin-access');
return Theme::render('admin.create_user');
}
/**
* Store a newly created resource in storage.
*
* @param \Illuminate\Http\Request $request
* @return \Illuminate\Http\Response
*/
public function store(Requests\StoreUserRequest $request)
{
$this->authorize('admin-access');
$user = new User();
$user->fill($request->only(['name', 'email', 'password']));
$user->is_activated = true;
$user->is_admin = (strtolower($request->get('is_admin')) == 'on');
$user->save();
return redirect(route('user.index'));
}
/**
* Display the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function show($id)
{
//
}
/**
* Show the form for editing the specified resource.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function edit($id)
{
//
}
/**
* Update the specified resource in storage.
*
* @param \Illuminate\Http\Request $request
* @param int $id
* @return \Illuminate\Http\Response
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*
* @param int $id
* @return \Illuminate\Http\Response
*/
public function destroy($id)
{
//
}
}

View File

@ -36,6 +36,15 @@ class RegisterController extends Controller
*/
protected $redirectTo = '/';
public static function passwordRequirements()
{
return [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
];
}
/**
* Create a new controller instance.
*
@ -54,25 +63,18 @@ class RegisterController extends Controller
*/
protected function validator(Request $request)
{
return Validator::make(
$request->all(),
[
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|min:6|confirmed',
]
)
->after(function($validator) use ($request)
{
// reCAPTCHA validation
if (
UserConfig::get('recaptcha_enabled_registration') &&
!RecaptchaHelper::validateResponse($request->request->get('g-recaptcha-response'), $request->getClientIp())
)
return Validator::make($request->all(), self::passwordRequirements())
->after(function($validator) use ($request)
{
$validator->errors()->add('recaptcha', trans('auth.recaptcha_failed_message'));
}
});
// reCAPTCHA validation
if (
UserConfig::get('recaptcha_enabled_registration') &&
!RecaptchaHelper::validateResponse($request->request->get('g-recaptcha-response'), $request->getClientIp())
)
{
$validator->errors()->add('recaptcha', trans('auth.recaptcha_failed_message'));
}
});
}
/**

View File

@ -48,6 +48,7 @@ class InstallController extends Controller
$canContinue = true;
$requiredModules = [
'curl' => 'installer.php_modules.curl',
'pdo_mysql' => 'installer.php_modules.mysql',
'gd' => 'installer.php_modules.gd'
];

View File

@ -0,0 +1,29 @@
<?php
namespace App\Http\Requests;
use App\Http\Controllers\Auth\RegisterController;
use Illuminate\Foundation\Http\FormRequest;
class StoreUserRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array
*/
public function rules()
{
return RegisterController::passwordRequirements();
}
}

View File

@ -17,6 +17,9 @@ return [
'create_album_no_storage' => 'There are currently no storage locations set up. Please create a location to store your photos before creating an album.',
'create_storage' => 'Create storage location',
'create_storage_intro' => 'Complete the form below to create a new storage location to hold your photos. You can then select this storage location when you create an album.',
'create_user' => 'Create user',
'create_user_intro' => 'You can use the form below to create a user account. Users created using this form will be activate immediately.',
'create_user_title' => 'Create a user account',
'delete_album' => 'Delete album :name',
'delete_album_confirm' => 'Are you sure you want to permanently delete this album and all its contents?',
'delete_album_warning' => 'This is a permanent action that cannot be undone!',
@ -83,5 +86,6 @@ return [
'upload_file_status_success' => ':file_name uploaded successfully',
'upload_single_file_heading' => 'Upload photos individually',
'upload_single_file_text' => 'You can use the form below to upload individual files. To upload multiple files at once, hold down CTRL in the file browser.',
'upload_single_file_text2' => 'Your web server is configured to allow files up to :file_size. If you browser does not support HTML 5 (most modern browsers do), the combined size of all selected files must be less than :max_upload_size.'
'upload_single_file_text2' => 'Your web server is configured to allow files up to :file_size. If you browser does not support HTML 5 (most modern browsers do), the combined size of all selected files must be less than :max_upload_size.',
'users_title' => 'User accounts'
];

View File

@ -1,5 +1,6 @@
<?php
return [
'admin_user_label' => 'User is an administrator',
'album_source_label' => 'Storage location:',
'apply_action' => 'Apply',
'bulk_edit_photos_label' => 'Bulk edit selected photos:',

View File

@ -18,6 +18,7 @@ return [
'upload_limit_warning' => 'We recommend a minimum of :size :units. This value is controlled by the upload_max_filesize php.ini setting.'
],
'php_modules' => [
'curl' => 'cURL Web Requests Library',
'gd' => 'GD Graphics Processing Library',
'heading' => 'Required PHP modules:',
'mysql' => 'MySQL Client Library'

View File

@ -5,6 +5,7 @@ return [
'albums' => 'Albums',
'create_album' => 'Create album',
'create_storage' => 'Create storage',
'create_user' => 'Create user',
'delete_album' => 'Delete album',
'delete_storage' => 'Delete storage location',
'edit_album' => 'Edit album',

View File

@ -0,0 +1,83 @@
@extends('themes.base.layout')
@section('title', trans('admin.create_user'))
@section('breadcrumb')
<div class="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">@lang('navigation.breadcrumb.home')</a></li>
<li><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li><a href="{{ route('albums.index') }}">@lang('navigation.breadcrumb.users')</a></li>
<li class="active">@lang('navigation.breadcrumb.create_user')</li>
</ol>
</div>
</div>
@endsection
@section('content')
<div class="container">
<div class="row">
<div class="col-xs-12">
<h1>@lang('admin.create_user_title')</h1>
<p>@lang('admin.create_user_intro')</p>
<hr/>
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $form_error)
<li>{{ $form_error }}</li>
@endforeach
</ul>
</div>
@endif
{!! Form::open(['route' => 'user.store', 'method' => 'POST']) !!}
<div class="row">
<div class="col-sm-6">
<div class="form-group">
{!! Form::label('name', trans('forms.name_label'), ['class' => 'control-label']) !!}
{!! Form::text('name', old('name'), ['class' => 'form-control']) !!}
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
{!! Form::label('email', trans('forms.email_label'), ['class' => 'control-label']) !!}
{!! Form::text('email', old('email'), ['class' => 'form-control']) !!}
</div>
</div>
</div>
<div class="row">
<div class="col-sm-6">
<div class="form-group">
{!! Form::label('password', trans('forms.password_label'), ['class' => 'control-label']) !!}
{!! Form::password('password', ['class' => 'form-control']) !!}
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
{!! Form::label('password_confirmation', trans('forms.password_confirm_label'), ['class' => 'control-label']) !!}
{!! Form::password('password_confirmation', ['class' => 'form-control']) !!}
</div>
</div>
</div>
<div class="checkbox">
<label>
<input type="checkbox" name="is_admin">
<strong>@lang('forms.admin_user_label')</strong>
</label>
</div>
<div class="form-actions">
<a href="{{ route('user.index') }}" class="btn btn-default">@lang('forms.cancel_action')</a>
{!! Form::submit(trans('forms.create_action'), ['class' => 'btn btn-success']) !!}
</div>
{!! Form::close() !!}
</div>
</div>
</div>
@endsection

View File

@ -0,0 +1,46 @@
@extends('themes.base.layout')
@section('title', trans('admin.users_title'))
@section('breadcrumb')
<div class="breadcrumb">
<div class="container">
<ol class="breadcrumb">
<li><a href="{{ route('home') }}">@lang('navigation.breadcrumb.home')</a></li>
<li><a href="{{ route('admin') }}">@lang('navigation.breadcrumb.admin')</a></li>
<li class="active">@lang('navigation.breadcrumb.users')</li>
</ol>
</div>
</div>
@endsection
@section('content')
<div class="container">
<div class="row">
<div class="col-xs-12">
<table class="table table-hover table-striped">
<tbody>
@foreach ($users as $user)
<tr>
<td>
<span style="font-size: 1.3em;">{{ $user->name }}@if ($user->is_admin) <i class="fa fa-fw fa-cog"></i>@endif</span><br/>
</td>
<td class="text-right">
<a href="{{ route('user.edit', ['id' => $user->id]) }}" class="btn btn-default">@lang('forms.edit_action')</a>
<a href="{{ route('user.delete', ['id' => $user->id]) }}" class="btn btn-danger">@lang('forms.delete_action')</a>
</td>
</tr>
@endforeach
</tbody>
</table>
<div class="text-center">
{{ $users->links() }}
</div>
<div class="pull-right" style="margin-top: 10px;">
<a href="{{ route('user.create') }}" class="btn btn-success"><i class="fa fa-fw fa-plus"></i> @lang('admin.create_user')</a>
</div>
</div>
</div>
</div>
@endsection

View File

@ -3,7 +3,7 @@
<div class="panel-body">
<ul class="nav nav-pills">
<li role="presentation"><a href="{{ route('albums.index') }}"><i class="fa fa-fw fa-picture-o"></i> @lang('navigation.breadcrumb.albums')</a></li>
<li role="presentation"><a href="#"><i class="fa fa-fw fa-user"></i> @lang('navigation.breadcrumb.users')</a></li>
<li role="presentation"><a href="{{ route('user.index') }}"><i class="fa fa-fw fa-user"></i> @lang('navigation.breadcrumb.users')</a></li>
<li role="presentation"><a href="{{ route('admin.settings') }}"><i class="fa fa-fw fa-cog"></i> @lang('navigation.breadcrumb.settings')</a></li>
<li role="presentation"><a href="{{ route('storage.index') }}"><i class="fa fa-fw fa-folder"></i> @lang('navigation.breadcrumb.storage')</a></li>
</ul>

View File

@ -36,6 +36,10 @@ Route::group(['prefix' => 'admin'], function () {
// Storage management
Route::get('storage/{id}/delete', 'Admin\StorageController@delete')->name('storage.delete');
Route::resource('storage', 'Admin\StorageController');
// User management
Route::get('user/{id}/delete', 'Admin\UserController@delete')->name('user.delete');
Route::resource('user', 'Admin\UserController');
});
// Installation