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\Requests;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
/**
|
||||
* Class Login
|
||||
@@ -15,22 +16,26 @@ use Illuminate\Http\Request;
|
||||
*/
|
||||
class Login extends Controller
|
||||
{
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
protected function validator(array $data)
|
||||
public function getLoginForm()
|
||||
{
|
||||
return Validator::make($data, [
|
||||
'name' => 'required|max:255',
|
||||
'email' => 'required|email|max:255|unique:users',
|
||||
'password' => 'required|confirmed|min:6',
|
||||
]);
|
||||
if (Auth::check()) {
|
||||
return redirect()->route('admin.dashboard');
|
||||
}
|
||||
|
||||
return view('admin.loginForm.form');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Request $request
|
||||
*
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
*/
|
||||
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)
|
||||
{
|
||||
if (Auth::guard($guard)->guest()) {
|
||||
if (Auth::check()) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
|
||||
+6
-7
@@ -2,25 +2,24 @@
|
||||
|
||||
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\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Symfony\Component\Process\Exception\InvalidArgumentException;
|
||||
use Illuminate\Foundation\Auth\Access\Authorizable;
|
||||
|
||||
/**
|
||||
* Class User
|
||||
*/
|
||||
class User extends Model
|
||||
class User extends Model implements AuthenticableInterface
|
||||
{
|
||||
use Authenticatable, Authorizable, CanResetPassword;
|
||||
public $timestamps = false;
|
||||
protected $fillable = [
|
||||
'email',
|
||||
'username',
|
||||
'password',
|
||||
'role',
|
||||
'name',
|
||||
'status'
|
||||
];
|
||||
protected $guarded = [];
|
||||
/**
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
-- 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
|
||||
-- MySQL Workbench Forward Engineering
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
<label>
|
||||
@lang('admin/loginForm.email')
|
||||
<input type="text" placeholder="somebody@example.com">
|
||||
<input type="text" placeholder="somebody@example.com" name="email">
|
||||
|
||||
@if ($errors->has('email'))
|
||||
<span class="help-block">
|
||||
@@ -26,7 +26,7 @@
|
||||
|
||||
<label>
|
||||
@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'))
|
||||
<span class="help-block">
|
||||
@@ -41,7 +41,7 @@
|
||||
</label>
|
||||
|
||||
<p>
|
||||
<a type="submit" class="button expanded">@lang('admin/loginForm.login')</a>
|
||||
<button type="submit" class="button expanded">@lang('admin/loginForm.login')</button>
|
||||
</p>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user