eOSP2/app/Http/Controllers/SessionsController.php

39 lines
854 B
PHP
Raw Normal View History

2019-09-11 00:09:22 +02:00
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class SessionsController extends Controller
{
public function create()
{
return view('login');
}
public function store()
{
2019-09-17 19:59:20 +02:00
if (auth()->attempt(request(['email', 'password'])) == false) {
2019-09-11 00:09:22 +02:00
return back()->withErrors([
2020-01-31 19:07:55 +01:00
'message' => 'Podany adres email lub hasło jest nieprawidłowe, proszę spróbować ponownie.'
2019-09-11 00:09:22 +02:00
]);
}
2020-01-31 19:07:55 +01:00
elseif(auth()->user()->statusID == 1)
{
auth()->logout();
return back()->withErrors([
'message' => 'Twoje konto zostało zawieszone.'
]);
}
2019-09-11 00:09:22 +02:00
return redirect()->to('/jednostka');
}
public function destroy()
{
auth()->logout();
return redirect()->to('/login');
}
}