Hi,
for a very small project, I am asked to create a custom authentication layer which works in this way:
So basically it is an ip-based authentication, and the user doesn't need to insert any kind of other information (don't worry about security, ip spoofing and so on, it is not relevant here)
How can I do this in laravel?
Thank you
hmm doesn't sound that bad. Here are my quick thoughts.
First create your own "AuthController". This is going to be your main item here. You will want this to do the heavy lifting. All you really need is the one function, and you can refactor it as you please.
public function login()
{
$ip = $_SERVER['REMOTE_ADDR'];
$result = shell_exec('something');
$user = User::where('id', $result)->first();
if(! $user) {
return 'user not found in usertable';
}
auth()->login($user); // or \Auth::login($user);
return redirect()->route('home');
}
Anyway first thoughts, so the login goes to that "route" and it would handle the informtion.
Thank you, it was not so hard as I thought, I created an AuthController based on your sketch, and it works perfectly.
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community