Asked by: Murali Krishna
In laravel5.4 i have one call page which is accessable by authenticated users. But in my application i have a feature like "invite user". If we invite user who are not part of my application they can also join in call page. But this type of users are not stored in users table. I will store in another table like guestusers. When ever snding the invitation i will add that into this table along with unique token. i will send a link along with this token to guest user. But how to authenticate this type of users in laravel?
Answers
Answered by: Murali Krishna at 2017-07-11 05:13PM
Here is my authenticate.php code
public function handle($request, Closure $next, $guard = null)
{
if ($this->auth->guest()) {
if ($request->ajax() || $request->wantsJson()) {
if($guard=='api'){
if(Auth::guard('api')->user()==null)
return response()->json(['status'=>'401','message' => 'Unauthorized']);
}
else {
return response('Unauthorized.', 401);
}
} else {
return redirect()->guest('/');
}
}
return $next($request);
}
i have web routes and api routes. but how to authenticate these token based invited users? we are not saving these in to users table.
No comments:
Post a Comment