mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 05:58:34 +01:00
MDL-60905 auth_email: remember loginpage wantsurl for account creation
this allows for redirecting to the correct location upon account confirmation ;)
This commit is contained in:
parent
5bde2c2b62
commit
feb23f1b96
@ -113,7 +113,7 @@ class auth_plugin_email extends auth_plugin_base {
|
||||
* @since Moodle 3.2
|
||||
*/
|
||||
public function user_signup_with_confirmation($user, $notify=true, $confirmationurl = null) {
|
||||
global $CFG, $DB;
|
||||
global $CFG, $DB, $SESSION;
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
require_once($CFG->dirroot.'/user/lib.php');
|
||||
|
||||
@ -130,6 +130,11 @@ class auth_plugin_email extends auth_plugin_base {
|
||||
// Save any custom profile field information.
|
||||
profile_save_data($user);
|
||||
|
||||
// Save wantsurl against user's profile, so we can return them there upon confirmation.
|
||||
if (!empty($SESSION->wantsurl)) {
|
||||
set_user_preference('auth_email_wantsurl', $SESSION->wantsurl, $user);
|
||||
}
|
||||
|
||||
// Trigger event.
|
||||
\core\event\user_created::create_from_userid($user->id)->trigger();
|
||||
|
||||
@ -166,7 +171,7 @@ class auth_plugin_email extends auth_plugin_base {
|
||||
* @param string $confirmsecret
|
||||
*/
|
||||
function user_confirm($username, $confirmsecret) {
|
||||
global $DB;
|
||||
global $DB, $SESSION;
|
||||
$user = get_complete_user_data('username', $username);
|
||||
|
||||
if (!empty($user)) {
|
||||
@ -178,6 +183,13 @@ class auth_plugin_email extends auth_plugin_base {
|
||||
|
||||
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
|
||||
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
|
||||
|
||||
if ($wantsurl = get_user_preferences('auth_email_wantsurl', false, $user)) {
|
||||
// Ensure user gets returned to page they were trying to access before signing up.
|
||||
$SESSION->wantsurl = $wantsurl;
|
||||
unset_user_preference('auth_email_wantsurl', $user);
|
||||
}
|
||||
|
||||
return AUTH_CONFIRM_OK;
|
||||
}
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user