My Laravel instance doesn't remember that a user is logged in. When I type Auth::user()->accountName
it tells me what I want in the LoginController
, but on the site, I need it to confirm that the user is logged in, but it doesn't work.
When I return the view('neu_anmeldung') in the MainController
, I can check if the user is logged in and it works. The problem is when I click on another link on the navbar it automatically logs out and the MainController
doesn't work when it checks in the view. I think it only saves the Auth::user()
variable locally because i can access it from the MainController
but not the view.
Controller
<?php
// My Login Controller
class MainController extends Authenticate
{
function index()
{
return view('home');
}
function checklogin(Request $request)
{
$user = Input::get('user');
$pwd = Input::get('password');
try {
$validated = $request->validate([
'user' => 'required',
'password' => 'required|min:3'
]);
$user = pupil::where('accountName', $user)
->where('password', $pwd)
->first();
if ($user) {
Auth::login($user);
return redirect('/successlogin');
} else {
return redirect()->back()->withInput('email');
}
} catch (QueryException $e) {
return back()->withError($e->getMessage())->withInput();
}
}
function successlogin()
{
return redirect('/neue_anmeldung');
}
function logout()
{
Auth::logout();
return redirect('/index');
}
}
View
@if(isset(Auth::user()->accountName))
<div class="alert">
<strong>Wilkommen {{Auth::user()->accountName}}</strong>
<br/>
<a href="{{url('/index/logout')}}">Logout</a>
</div>
@else
<script>window.location = "/index";</script>
@endif
Model
namespace App;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
class pupil extends Authenticatable
{
use Notifiable;
protected $table = 'pupil';
protected $fillable = [
'name', 'email', 'password',
];
protected $hidden = [
'password', 'remember_token',
];
}
Firebase Cloud Functions: PubSub, "res.on is not a function"
TypeError: Cannot read properties of undefined (reading 'createMessageComponentCollector')
I am maintaining many copies of one application (built on Laravel) on different hosts, and I am looking for a way to check if Laravel Schedule is actually running for eachDoes Laravel offer something for that?
I have been following the latest writeup from Microsoft in an effort to generate an account level Shared Access Signature (SAS) for use with Azure storage services, notably Blobs
I have a script file named bphp which I can execute it with proc_open with below code successfully and without any problem:
I have to extract the attribute 'gigabyte' from products description, I need a function that extract substring between its closer space recurrence and GB