This repository was archived by the owner on May 9, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Authentication
Timothy Seebus edited this page Jul 12, 2014
·
6 revisions
in this instance camelot auth expects the url to contain the name of authentication provider you want to call for example
http://www.domain.com/login/facebook
this route will call the login page and call the oauth2 driver with the settings for the facebook authentication provider
Route::any('login/{provider?}/{callback?}',function(){
try
{
Camelot::authenticate();
if(Camelot::check()){
echo 'Welcome'.Camelot::User()->first_name.' '.Camelot::User()->last_name.' you have been successfully logged in';
}
}
catch(\Exception $e)
{
echo 'user could not be logged in';
}
});in this instance you will specify the required driver and authentication provider and then try to authenticate
Route::any('login/{provider?}/{callback?}',function(){
try
{
Camelot::loadDriver('oauth2client','facebook');
Camelot::authenticate();
if(Camelot::check()){
echo 'Welcome'.Camelot::User()->first_name.' '.Camelot::User()->last_name.' you have been successfully logged in';
}
}
catch(\Exception $e)
{
echo 'user could not be logged in';
}
});some drivers (such as the form driver) expect credentials to be provided to be able to authenticate a user
Route::post('login',function(){
try
{
// lets specify the local form authentication driver
Camelot::loadDriver('local');
$credentials = array('username'=>'taftse','password'=>'Excalibur');
Camelot::authenticate($credentials);
if(Camelot::check()){
echo 'Welcome'.Camelot::User()->first_name.' '.Camelot::User()->last_name.' you have been successfully logged in';
}
}
catch(\Exception $e)
{
echo 'user could not be logged in';
}
});