File tree Expand file tree Collapse file tree
src/CoreBundle/Controller Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99use BuyCoursesPlugin ;
1010use Chamilo \CoreBundle \Component \Essence \SafeEssenceHttpClient ;
1111use Chamilo \CoreBundle \Entity \AccessUrlRelUser ;
12+ use Chamilo \CoreBundle \Entity \UserAuthSource ;
1213use Chamilo \CoreBundle \Entity \ExtraField ;
1314use Chamilo \CoreBundle \Entity \SequenceResource ;
1415use Chamilo \CoreBundle \Entity \Session ;
@@ -318,6 +319,23 @@ public function sendCourseNotification(
318319 $ rel ->setUrl ($ accessUrl );
319320
320321 $ em ->persist ($ rel );
322+
323+ // Copy the user's first auth source to the new URL so they can log in on it,
324+ // mirroring the behaviour of access_url_edit_users_to_url.php.
325+ $ alreadyHasAuthSource = $ user ->getAuthSourcesByUrl ($ accessUrl )->count () > 0 ;
326+ if (!$ alreadyHasAuthSource ) {
327+ $ firstAuthSource = $ user ->getAuthSources ()->first ();
328+ $ authentication = $ firstAuthSource
329+ ? $ firstAuthSource ->getAuthentication ()
330+ : UserAuthSource::PLATFORM ;
331+
332+ $ userAuthSource = new UserAuthSource ();
333+ $ userAuthSource ->setUser ($ user );
334+ $ userAuthSource ->setUrl ($ accessUrl );
335+ $ userAuthSource ->setAuthentication ($ authentication );
336+
337+ $ em ->persist ($ userAuthSource );
338+ }
321339 }
322340 }
323341
You can’t perform that action at this time.
0 commit comments