Skip to content

Commit

Permalink
Bug #8, Allow login-redirects to be disabled - PHP [iet:10314088]
Browse files Browse the repository at this point in the history
* `user_event_observer` class
  • Loading branch information
nfreear committed Mar 7, 2018
1 parent 0fe79c4 commit 5b809d9
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions classes/user_event_observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,21 @@ public static function embed_event_data(\core\event\base $event) {
protected static function redirect($user_created, $fn) {
global $CFG, $USER; // Moodle globals.

$redirects = $CFG->auth_ouopenid_redirects;
$enabled = isset($CFG->auth_ouopenid_redirect_enable) ? $CFG->auth_ouopenid_redirect_enable : null;
$redirects = isset($CFG->auth_ouopenid_redirects) ? $CFG->auth_ouopenid_redirects : null;

if (! isset($USER->username)) {
return self::debug([ __FUNCTION__, 'Warning, nno username.', $USER ]);
return OuUser::debug([ __FUNCTION__, 'Warning, no username.', $USER ]);
}

$ou_profile = OuUser::getUser($USER->username);

OuUser::debug([ __FUNCTION__, $fn, $redirects, $ou_profile ]);

if (! $redirects || ! $enabled) {
return OuUser::debug([ __FUNCTION__, 'Warning, redirect is disabled (or missing).', $redirects ]);
}

$url = OuUser::getRedirectUrl($ou_profile, $user_created ? 'newenrol' : 'return');

header('Location: '. $url, true, 302);
Expand Down

0 comments on commit 5b809d9

Please sign in to comment.