2017-06-20 08:43:36 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
|
|
class SessionsController extends Controller
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
function __construct() {
|
|
|
|
|
$this->middleware('guest', ['except' => 'destroy']); // Filter: Only guests = not logged in users are allowed. Everybody else is redirected away.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function create() {
|
|
|
|
|
return view('sessions.create');
|
|
|
|
|
}
|
|
|
|
|
public function store() {
|
|
|
|
|
// Attempt to authenticate the user
|
|
|
|
|
|
2017-08-01 14:33:22 +02:00
|
|
|
$name=request('firstname')." ".request('lastname');
|
|
|
|
|
$password=request('password');
|
|
|
|
|
|
|
|
|
|
if (!auth()->attempt(['name'=>$name, 'password'=>$password])) {
|
2017-06-20 08:43:36 +02:00
|
|
|
return back()->withErrors(['message'=>'Bitte Logindaten prüfen und nochmal versuchen.']);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// And redirect to home page
|
|
|
|
|
return redirect()->home();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
public function destroy() {
|
|
|
|
|
auth()->logout();
|
|
|
|
|
return redirect()->home();
|
|
|
|
|
}
|
|
|
|
|
}
|