I have a user login system that consists of two steps:
- User Login
- Attempt to bind user to AD (This is the LDAP auth module)
- If user can login via AD, check if the user exists in the Users table
- If user doesn't exist in Users table, add them - only the "username" and "nice name"
- If user is added, they will not belong to any teams and will be notified to contact their manager to continue account setup.
- Load user columns into Laravel Session
credentials
- so now we have AD login name, "nice" name (first last), selected team ID, etc.. no passwords because user has authenticated.
- Team selection - table
userTeams
pivot table. - Route user to team dashboard
Right now, I have this route:
// This group forces user to be logged in; auth() will check if user has selected a team and ensures the team exists.
Route::group(array('before' => 'auth'), function() {
// Handle team - URL will be /dashboard -- Team controller based on view_name from `teamUsers` table
$teamUser = php_sapi_name() == "cli" ? null : @TeamUser::find(Session::get('credentials.team'));
if(!empty($teamUser)) {
$team = ucfirst(strtolower($teamUser->teams()->first()->view_name));
Route::controller('dashboard', 'Team'.$team.'Controller');
}
// Handle index
Route::controller('/', 'IndexController');
});
However, I don't feel this is a very elegant solution - mostly because I cannot do reverse routing doing this method.
Any tips or suggestions?