Merge branch 'authentication' into user_management

This commit is contained in:
Michal Kváček
2016-01-20 23:54:21 +01:00
25 changed files with 14137 additions and 85 deletions
@@ -1,6 +1,6 @@
<?php
namespace App\Http\Controllers\Auth;
namespace App\Http\Controllers\Admin;
use App\User;
use Validator;
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Http\Controllers\Admin;
use Illuminate\Http\Request;
use App\Http\Requests;
use App\Http\Controllers\Controller;
class Dashboard extends Controller
{
//
}
+36
View File
@@ -0,0 +1,36 @@
<?php
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use App\Http\Requests;
use Illuminate\Http\Request;
/**
* Class Login
*
* @package App\Http\Controllers\Admin
*
* @todo use trait ThrottlesLogins for disabling brutal-force password cracking
*/
class Login extends Controller
{
/**
* @param array $data
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|max:255',
'email' => 'required|email|max:255|unique:users',
'password' => 'required|confirmed|min:6',
]);
}
/**
* @param Request $request
*/
public function postLogin(Request $request)
{
}
}
@@ -1,6 +1,6 @@
<?php
namespace App\Http\Controllers\Auth;
namespace App\Http\Controllers\Admin;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
+16 -4
View File
@@ -11,7 +11,6 @@
|
*/
/*
|--------------------------------------------------------------------------
| Application Routes
@@ -23,8 +22,21 @@
|
*/
Route::group(['middleware' => ['web']], function () {
Route::get('/test', 'TestController@showIndex');
Route::get('login', function () {
return view('admin.loginForm.form');
});
// POST methods
Route::post('admin/login', 'Admin\Login@postLogin')
->name('login');
});
// list of admin routes
Route::group([
'middleware' => ['auth'],
'namespace' => 'Admin',
'prefix' => 'admin'
], function () {
Route::get('/', 'Dashboard@getIndex');
});
+8
View File
@@ -23,5 +23,13 @@ class User extends Model
protected $guarded = [];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
class GlobalViewDataProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
view()->share('something', 'some value');
view()->share('vendorName', 'ja s.r.o.');
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
//
}
}
-26
View File
@@ -1,26 +0,0 @@
<?php
namespace App;
use Illuminate\Foundation\Auth\User as Authenticatable;
class User extends Authenticatable
{
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes excluded from the model's JSON form.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
}
+1
View File
@@ -155,6 +155,7 @@ return [
App\Providers\AuthServiceProvider::class,
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,
App\Providers\GlobalViewDataProvider::class,
],
+1 -1
View File
@@ -67,7 +67,7 @@ return [
'providers' => [
'users' => [
'driver' => 'eloquent',
'model' => App\User::class,
'model' => App\Models\User::class,
],
// 'users' => [
+49 -52
View File
@@ -14,20 +14,17 @@ SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
-- -----------------------------------------------------
-- Schema minicms
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `minicms` DEFAULT CHARACTER SET utf8 ;
USE `minicms` ;
-- -----------------------------------------------------
-- Table `minicms`.`user`
-- Table `user`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`user` (
CREATE TABLE IF NOT EXISTS `user` (
`id` INT NOT NULL AUTO_INCREMENT,
`email` VARCHAR(64) NOT NULL COMMENT 'E-mail is used as a contact and also as a username',
`username` VARCHAR(64) NOT NULL,
`username` VARCHAR(64) NOT NULL COMMENT 'Username can be used also for login. Default value is users email.',
`password` VARCHAR(128) NOT NULL COMMENT 'Password hash',
`remember_token` VARCHAR(128) NULL DEFAULT NULL COMMENT 'Token used for \"remember me\" feature',
`name` VARCHAR(128) NULL DEFAULT NULL,
`status` ENUM('deleted', 'blocked', 'active') NULL DEFAULT 'active' COMMENT 'Username can be used also for login. Default value is users email.',
`status` ENUM('deleted', 'blocked', 'active') NOT NULL DEFAULT 'active' ,
PRIMARY KEY (`id`),
UNIQUE INDEX `email_UNIQUE` (`email` ASC))
ENGINE = InnoDB
@@ -35,9 +32,9 @@ COMMENT = 'Table with users who are allowed to log into system';
-- -----------------------------------------------------
-- Table `minicms`.`module`
-- Table `module`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`module` (
CREATE TABLE IF NOT EXISTS `module` (
`handler` VARCHAR(64) NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`name` VARCHAR(64) NOT NULL,
@@ -47,9 +44,9 @@ ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `minicms`.`file`
-- Table `file`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`file` (
CREATE TABLE IF NOT EXISTS `file` (
`id` INT NOT NULL,
`user_id` INT NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
@@ -60,7 +57,7 @@ CREATE TABLE IF NOT EXISTS `minicms`.`file` (
INDEX `fk_file_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_file_user1`
FOREIGN KEY (`user_id`)
REFERENCES `minicms`.`user` (`id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
@@ -68,9 +65,9 @@ COMMENT = 'Table containing files which were uploaded into system.';
-- -----------------------------------------------------
-- Table `minicms`.`content`
-- Table `content`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`content` (
CREATE TABLE IF NOT EXISTS `content` (
`id` INT NOT NULL,
`user_id` INT NOT NULL,
`module_handler` VARCHAR(64) NOT NULL,
@@ -95,17 +92,17 @@ CREATE TABLE IF NOT EXISTS `minicms`.`content` (
INDEX `fk_content_file1_idx` (`title_photo` ASC),
CONSTRAINT `fk_content_user1`
FOREIGN KEY (`user_id`)
REFERENCES `minicms`.`user` (`id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_content_module1`
FOREIGN KEY (`module_handler`)
REFERENCES `minicms`.`module` (`handler`)
REFERENCES `module` (`handler`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_content_file1`
FOREIGN KEY (`title_photo`)
REFERENCES `minicms`.`file` (`id`)
REFERENCES `file` (`id`)
ON DELETE SET NULL
ON UPDATE CASCADE)
ENGINE = InnoDB
@@ -113,9 +110,9 @@ COMMENT = 'Table with all content pages.';
-- -----------------------------------------------------
-- Table `minicms`.`content_history`
-- Table `content_history`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`content_history` (
CREATE TABLE IF NOT EXISTS `content_history` (
`id` INT NOT NULL,
`user_id` INT NOT NULL,
`content_id` INT NOT NULL,
@@ -131,12 +128,12 @@ CREATE TABLE IF NOT EXISTS `minicms`.`content_history` (
INDEX `fk_content_history_content1_idx` (`content_id` ASC),
CONSTRAINT `fk_content_history_users`
FOREIGN KEY (`user_id`)
REFERENCES `minicms`.`user` (`id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_content_history_content1`
FOREIGN KEY (`content_id`)
REFERENCES `minicms`.`content` (`id`)
REFERENCES `content` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
@@ -144,9 +141,9 @@ COMMENT = 'Table for holding history of changes on some content.';
-- -----------------------------------------------------
-- Table `minicms`.`widget_type`
-- Table `widget_type`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`widget_type` (
CREATE TABLE IF NOT EXISTS `widget_type` (
`handler` VARCHAR(64) NOT NULL COMMENT 'Class wich handles everything about this widget type',
`name` VARCHAR(64) NOT NULL COMMENT 'Name is used only in admin for better readability.',
`description` TEXT NULL DEFAULT NULL COMMENT 'This field also improves readability.',
@@ -156,9 +153,9 @@ COMMENT = 'Widget type table contains information about all installed widgets. T
-- -----------------------------------------------------
-- Table `minicms`.`widget`
-- Table `widget`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`widget` (
CREATE TABLE IF NOT EXISTS `widget` (
`id` INT NOT NULL,
`widget_type_handler` VARCHAR(64) NOT NULL,
`user_id` INT NOT NULL COMMENT 'User ID who created this widget',
@@ -171,12 +168,12 @@ CREATE TABLE IF NOT EXISTS `minicms`.`widget` (
INDEX `fk_widget_widget_type1_idx` (`widget_type_handler` ASC),
CONSTRAINT `fk_widget_user1`
FOREIGN KEY (`user_id`)
REFERENCES `minicms`.`user` (`id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_widget_widget_type1`
FOREIGN KEY (`widget_type_handler`)
REFERENCES `minicms`.`widget_type` (`handler`)
REFERENCES `widget_type` (`handler`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
@@ -184,9 +181,9 @@ COMMENT = 'Widget is a small piece of content, which can be inserted into widget
-- -----------------------------------------------------
-- Table `minicms`.`widget_area`
-- Table `widget_area`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`widget_area` (
CREATE TABLE IF NOT EXISTS `widget_area` (
`id` INT NOT NULL,
`created_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
`updated_at` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
@@ -200,9 +197,9 @@ COMMENT = 'Widget area is container for widgets. This container is inserted into
-- -----------------------------------------------------
-- Table `minicms`.`widget_in_widget_area`
-- Table `widget_in_widget_area`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`widget_in_widget_area` (
CREATE TABLE IF NOT EXISTS `widget_in_widget_area` (
`widget_id` INT NOT NULL,
`widget_area_id` INT NOT NULL,
`position` INT NOT NULL COMMENT 'Which position should the widget take?',
@@ -212,21 +209,21 @@ CREATE TABLE IF NOT EXISTS `minicms`.`widget_in_widget_area` (
INDEX `position` (`position` ASC),
CONSTRAINT `fk_widget_has_widget_area_widget1`
FOREIGN KEY (`widget_id`)
REFERENCES `minicms`.`widget` (`id`)
REFERENCES `widget` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_widget_has_widget_area_widget_area1`
FOREIGN KEY (`widget_area_id`)
REFERENCES `minicms`.`widget_area` (`id`)
REFERENCES `widget_area` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `minicms`.`custom_field`
-- Table `custom_field`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`custom_field` (
CREATE TABLE IF NOT EXISTS `custom_field` (
`id` INT NOT NULL,
`handler` VARCHAR(64) NOT NULL COMMENT 'Class name, which handles saving and retrieving given custom field.',
`name` VARCHAR(128) NULL,
@@ -242,9 +239,9 @@ COMMENT = 'List of all custom fields which may be used for extending some part o
-- -----------------------------------------------------
-- Table `minicms`.`user_has_custom_field`
-- Table `user_has_custom_field`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`user_has_custom_field` (
CREATE TABLE IF NOT EXISTS `user_has_custom_field` (
`user_id` INT NOT NULL,
`custom_field_id` INT NOT NULL,
`value` TEXT NOT NULL,
@@ -253,21 +250,21 @@ CREATE TABLE IF NOT EXISTS `minicms`.`user_has_custom_field` (
INDEX `fk_user_has_custom_field_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_user_has_custom_field_user1`
FOREIGN KEY (`user_id`)
REFERENCES `minicms`.`user` (`id`)
REFERENCES `user` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_user_has_custom_field_custom_field1`
FOREIGN KEY (`custom_field_id`)
REFERENCES `minicms`.`custom_field` (`id`)
REFERENCES `custom_field` (`id`)
ON DELETE CASCADE
ON UPDATE CASCADE)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `minicms`.`custom_field_type`
-- Table `custom_field_type`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`custom_field_type` (
CREATE TABLE IF NOT EXISTS `custom_field_type` (
`id` INT NOT NULL,
`name` VARCHAR(45) NOT NULL,
`custom_field_id` INT NOT NULL,
@@ -276,7 +273,7 @@ CREATE TABLE IF NOT EXISTS `minicms`.`custom_field_type` (
INDEX `fk_custom_field_type_custom_field1_idx` (`custom_field_id` ASC),
CONSTRAINT `fk_custom_field_type_custom_field1`
FOREIGN KEY (`custom_field_id`)
REFERENCES `minicms`.`custom_field` (`id`)
REFERENCES `custom_field` (`id`)
ON DELETE RESTRICT
ON UPDATE NO ACTION)
ENGINE = InnoDB
@@ -284,9 +281,9 @@ COMMENT = 'List of all custom field types.';
-- -----------------------------------------------------
-- Table `minicms`.`module_has_custom_field`
-- Table `module_has_custom_field`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`module_has_custom_field` (
CREATE TABLE IF NOT EXISTS `module_has_custom_field` (
`module_handler` VARCHAR(64) NOT NULL,
`custom_field_id` INT NOT NULL,
`value` TEXT NOT NULL,
@@ -295,21 +292,21 @@ CREATE TABLE IF NOT EXISTS `minicms`.`module_has_custom_field` (
INDEX `fk_module_has_custom_field_module1_idx` (`module_handler` ASC),
CONSTRAINT `fk_module_has_custom_field_module1`
FOREIGN KEY (`module_handler`)
REFERENCES `minicms`.`module` (`handler`)
REFERENCES `module` (`handler`)
ON DELETE CASCADE
ON UPDATE CASCADE,
CONSTRAINT `fk_module_has_custom_field_custom_field1`
FOREIGN KEY (`custom_field_id`)
REFERENCES `minicms`.`custom_field` (`id`)
REFERENCES `custom_field` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB;
-- -----------------------------------------------------
-- Table `minicms`.`action_log_type`
-- Table `action_log_type`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`action_log_type` (
CREATE TABLE IF NOT EXISTS `action_log_type` (
`id` INT NOT NULL,
`name` VARCHAR(45) NULL,
PRIMARY KEY (`id`))
@@ -318,9 +315,9 @@ COMMENT = 'List of all types which can be logged.';
-- -----------------------------------------------------
-- Table `minicms`.`action_log`
-- Table `action_log`
-- -----------------------------------------------------
CREATE TABLE IF NOT EXISTS `minicms`.`action_log` (
CREATE TABLE IF NOT EXISTS `action_log` (
`id` INT NOT NULL,
`type_id` INT NOT NULL,
`user_id` INT NOT NULL,
@@ -331,12 +328,12 @@ CREATE TABLE IF NOT EXISTS `minicms`.`action_log` (
INDEX `fk_action_log_user1_idx` (`user_id` ASC),
CONSTRAINT `fk_action_log_action_log_type1`
FOREIGN KEY (`type_id`)
REFERENCES `minicms`.`action_log_type` (`id`)
REFERENCES `action_log_type` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION,
CONSTRAINT `fk_action_log_user1`
FOREIGN KEY (`user_id`)
REFERENCES `minicms`.`user` (`id`)
REFERENCES `user` (`id`)
ON DELETE NO ACTION
ON UPDATE NO ACTION)
ENGINE = InnoDB
+9
View File
@@ -0,0 +1,9 @@
.login-form {
margin-top: 4em;
}
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
View File
+1
View File
@@ -0,0 +1 @@
$(document).foundation();
+7698
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1
View File
@@ -0,0 +1 @@
!function(e,t){"function"==typeof define&&define.amd?define([],function(){return t()}):"object"==typeof exports?module.exports=t():e.whatInput=t()}(this,function(){"use strict";function e(e){clearTimeout(s),n(e),f=!0,s=setTimeout(function(){f=!1},1e3)}function t(e){f||n(e)}function n(e){var t=o(e),n=r(e),d=w[e.type];"pointer"===d&&(d=i(e)),p!==d&&(!y&&p&&"keyboard"===d&&"tab"!==v[t]&&m.indexOf(n.nodeName.toLowerCase())>=0||(p=d,a.setAttribute("data-whatinput",p),-1===h.indexOf(p)&&h.push(p))),"keyboard"===d&&u(t)}function o(e){return e.keyCode?e.keyCode:e.which}function r(e){return e.target||e.srcElement}function i(e){return"number"==typeof e.pointerType?b[e.pointerType]:e.pointerType}function u(e){-1===c.indexOf(v[e])&&v[e]&&c.push(v[e])}function d(e){var t=o(e),n=c.indexOf(v[t]);-1!==n&&c.splice(n,1)}var s,c=[],a=document.body,f=!1,p=null,m=["input","select","textarea"],y=a.hasAttribute("data-whatinput-formtyping"),w={keydown:"keyboard",mousedown:"mouse",mouseenter:"mouse",touchstart:"touch",pointerdown:"pointer",MSPointerDown:"pointer"},h=[],v={9:"tab",13:"enter",16:"shift",27:"esc",32:"space",37:"left",38:"up",39:"right",40:"down"},b={2:"touch",3:"touch",4:"mouse"};return function(){var n="mousedown";window.PointerEvent?n="pointerdown":window.MSPointerEvent&&(n="MSPointerDown"),a.addEventListener(n,t),a.addEventListener("mouseenter",t),"ontouchstart"in document.documentElement&&a.addEventListener("touchstart",e),a.addEventListener("keydown",t),a.addEventListener("keyup",d)}(),{ask:function(){return p},keys:function(){return c},types:function(){return h},set:n}});
+10
View File
@@ -0,0 +1,10 @@
<?php
return [
'pageName' => 'Login form',
'formHeading' => 'Login with your e-mail',
'email' => 'E-mail used for login',
'password' => 'Password',
'rememberMe' => 'Remember me',
'forgottenPassword' => 'Did you forgot your password?',
'login' => 'Login'
];
+24
View File
@@ -0,0 +1,24 @@
<!doctype html>
<html class="no-js" lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
@yield('head_meta')
<title>@yield('pageName') {{$vendorName}}</title>
<link rel="stylesheet" href="{{asset('../resources/assets/css/foundation.css')}}" />
<link rel="stylesheet" href="{{asset('../resources/assets/css/admin.css')}}" />
@yield('head_stylesheets')
</head>
<body>
@yield('content')
<script src="{{asset('../resources/assets/js/vendor/jquery.min.js')}}"></script>
<script src="{{asset('../resources/assets/js/vendor/what-input.min.js')}}"></script>
<script src="{{asset('../resources/assets/js/foundation.min.js')}}"></script>
@yield('javascripts')
</body>
</html>
@@ -0,0 +1,50 @@
@extends('admin.layout')
{{--Set page name--}}
@section('pageName', @trans('admin/loginForm.pageName'))
@section('content')
<div class="row">
<div class="medium-6 medium-centered large-4 large-centered columns login-form">
<form method="POST" action="{{ route('login') }}">
{!! csrf_field() !!}
<div class="row column log-in-form{{ $errors->has('email') ? ' has-error' : '' }}">
<h4 class="text-center">@lang('admin/loginForm.formHeading')</h4>
<label>
@lang('admin/loginForm.email')
<input type="text" placeholder="somebody@example.com">
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</label>
<label>
@lang('admin/loginForm.password')
<input type="password" placeholder="@lang('admin/loginForm.password')">
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</label>
<label>
@lang('admin/loginForm.rememberMe')
<input type="checkbox" name="remember">
</label>
<p>
<a type="submit" class="button expanded">@lang('admin/loginForm.login')</a>
</p>
</div>
</form>
</div>
</div>
@stop