1
0
forked from s421507/eOSP2

Wstepne logowanie

This commit is contained in:
czup 2019-09-11 00:09:22 +02:00
parent 07471473ad
commit 6c2710feed
8 changed files with 75 additions and 10 deletions

View File

@ -0,0 +1,31 @@
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SessionsController extends Controller
{
public function create()
{
return view('login');
}
public function store()
{
if (auth()->attempt(request(['login', 'password'])) == false) {
return back()->withErrors([
'message' => 'The email or password is incorrect, please try again'
]);
}
return redirect()->to('/jednostka');
}
public function destroy()
{
auth()->logout();
return redirect()->to('/login');
}
}

View File

@ -67,7 +67,7 @@ return [
'providers' => [ 'providers' => [
'users' => [ 'users' => [
'driver' => 'eloquent', 'driver' => 'eloquent',
'model' => App\Uzytkownik::class, 'model' => App\User::class,
], ],
// 'users' => [ // 'users' => [

View File

@ -12,6 +12,6 @@
@section('center-area') @section('center-area')
@parent @parent
@include('inc.login') @include('inc.loginXX')
@stop @stop

View File

@ -3,17 +3,17 @@
{{ csrf_field() }} {{ csrf_field() }}
<div class="form-group"> <div class="form-group">
<label for="title">Login</label> <label for="title">Login</label>
<input type="text" class="form-control" id="userLogin" name="userLogin"> <input type="text" class="form-control" id="login" name="login">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="title">Hasło</label> <label for="title">Hasło</label>
<input type="text" class="form-control" id="userPassword" name="userPassword"> <input type="text" class="form-control" id="password" name="password">
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="title">Powtórz Hasło</label> <label for="title">Powtórz Hasło</label>
<input type="text" class="form-control" id="userPassword2" name="userPassword2"> <input type="text" class="form-control" id="password2" name="password2">
</div> </div>
@if ($errors->any()) @if ($errors->any())

View File

@ -7,6 +7,14 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
</head> </head>
<body> <body>
@if( auth()->check() )
{{ auth()->user()->name }}
{{ auth()->user()->surname }}
<a href="/logout">Logout</a>
@else
<a href="/login">Login</a>
<a href="/register">Register</a>
@endif
<div id="header"> <div id="header">
<div class="logo"><a href="/register"><img src="img/logo.png"></a></div> <div class="logo"><a href="/register"><img src="img/logo.png"></a></div>
@include('inc.menu') @include('inc.menu')

View File

@ -0,0 +1,25 @@
@extends('layout.app')
@section('center-area')
@parent
<h2>Log In</h2>
<form method="POST" action="/login">
{{ csrf_field() }}
<div class="form-group">
<label for="name">Login:</label>
<input type="text" class="form-control" id="login" name="login">
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" id="password" name="password">
</div>
<div class="form-group">
<button style="cursor:pointer" type="submit" class="btn btn-primary">Login</button>
</div>
{{-- @include('partials.formerrors')--}}
</form>
@endsection

View File

@ -45,8 +45,9 @@ Route::post('/register', 'RegistrationController@store');
Route::get('/login', 'LogowanieController@showLogin'); Route::get('/login', 'SessionsController@create');
Route::post('/login', 'LogowanieController@doLogin'); Route::post('/login', 'SessionsController@store');
Route::get('/logout', 'SessionsController@destroy');
//Auth::routes(); //Auth::routes();