Merge branch 'authentication' into user_management
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin;
|
|||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use App\Http\Requests;
|
use App\Http\Requests;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class Login
|
* Class Login
|
||||||
@@ -15,22 +16,26 @@ use Illuminate\Http\Request;
|
|||||||
*/
|
*/
|
||||||
class Login extends Controller
|
class Login extends Controller
|
||||||
{
|
{
|
||||||
/**
|
public function getLoginForm()
|
||||||
* @param array $data
|
|
||||||
*/
|
|
||||||
protected function validator(array $data)
|
|
||||||
{
|
{
|
||||||
return Validator::make($data, [
|
if (Auth::check()) {
|
||||||
'name' => 'required|max:255',
|
return redirect()->route('admin.dashboard');
|
||||||
'email' => 'required|email|max:255|unique:users',
|
}
|
||||||
'password' => 'required|confirmed|min:6',
|
|
||||||
]);
|
return view('admin.loginForm.form');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Request $request
|
* @param Request $request
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function postLogin(Request $request)
|
public function postLogin(Request $request)
|
||||||
{
|
{
|
||||||
|
if (Auth::attempt($request->only('email', 'password'))) {
|
||||||
|
return redirect()->route('admin.dashboard');
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "neplatne prihlaseni";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ class Authenticate
|
|||||||
*/
|
*/
|
||||||
public function handle($request, Closure $next, $guard = null)
|
public function handle($request, Closure $next, $guard = null)
|
||||||
{
|
{
|
||||||
if (Auth::guard($guard)->guest()) {
|
if (Auth::check()) {
|
||||||
if ($request->ajax()) {
|
if ($request->ajax()) {
|
||||||
return response('Unauthorized.', 401);
|
return response('Unauthorized.', 401);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+6
-7
@@ -2,25 +2,24 @@
|
|||||||
|
|
||||||
namespace App\Models;
|
namespace App\Models;
|
||||||
|
|
||||||
use App\Http\Requests\Request;
|
use Illuminate\Auth\Authenticatable;
|
||||||
|
use Illuminate\Auth\Passwords\CanResetPassword;
|
||||||
|
use Illuminate\Contracts\Auth\Authenticatable as AuthenticableInterface;
|
||||||
use Illuminate\Database\Eloquent\Model;
|
use Illuminate\Database\Eloquent\Model;
|
||||||
use Illuminate\Support\Facades\Validator;
|
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||||
use Illuminate\Validation\ValidationException;
|
|
||||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class User
|
* Class User
|
||||||
*/
|
*/
|
||||||
class User extends Model
|
class User extends Model implements AuthenticableInterface
|
||||||
{
|
{
|
||||||
|
use Authenticatable, Authorizable, CanResetPassword;
|
||||||
public $timestamps = false;
|
public $timestamps = false;
|
||||||
protected $fillable = [
|
protected $fillable = [
|
||||||
'email',
|
'email',
|
||||||
'username',
|
'username',
|
||||||
'password',
|
'password',
|
||||||
'role',
|
|
||||||
'name',
|
'name',
|
||||||
'status'
|
|
||||||
];
|
];
|
||||||
protected $guarded = [];
|
protected $guarded = [];
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
-- MySQL Script generated by MySQL Workbench
|
-- MySQL Script generated by MySQL Workbench
|
||||||
-- Čt 21. leden 2016, 00:19:53 CET
|
-- Čt 21. leden 2016, 01:17:14 CET
|
||||||
-- Model: New Model Version: 1.0
|
-- Model: New Model Version: 1.0
|
||||||
-- MySQL Workbench Forward Engineering
|
-- MySQL Workbench Forward Engineering
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
<label>
|
<label>
|
||||||
@lang('admin/loginForm.email')
|
@lang('admin/loginForm.email')
|
||||||
<input type="text" placeholder="somebody@example.com">
|
<input type="text" placeholder="somebody@example.com" name="email">
|
||||||
|
|
||||||
@if ($errors->has('email'))
|
@if ($errors->has('email'))
|
||||||
<span class="help-block">
|
<span class="help-block">
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
|
|
||||||
<label>
|
<label>
|
||||||
@lang('admin/loginForm.password')
|
@lang('admin/loginForm.password')
|
||||||
<input type="password" placeholder="@lang('admin/loginForm.password')">
|
<input type="password" placeholder="@lang('admin/loginForm.password')" name="password">
|
||||||
|
|
||||||
@if ($errors->has('password'))
|
@if ($errors->has('password'))
|
||||||
<span class="help-block">
|
<span class="help-block">
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
</label>
|
</label>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<a type="submit" class="button expanded">@lang('admin/loginForm.login')</a>
|
<button type="submit" class="button expanded">@lang('admin/loginForm.login')</button>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
Reference in New Issue
Block a user