mirror of
https://github.com/moodle/moodle.git
synced 2025-08-04 16:36:37 +02: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
1 changed files with 14 additions and 2 deletions
|
@ -113,7 +113,7 @@ class auth_plugin_email extends auth_plugin_base {
|
||||||
* @since Moodle 3.2
|
* @since Moodle 3.2
|
||||||
*/
|
*/
|
||||||
public function user_signup_with_confirmation($user, $notify=true, $confirmationurl = null) {
|
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/profile/lib.php');
|
||||||
require_once($CFG->dirroot.'/user/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.
|
// Save any custom profile field information.
|
||||||
profile_save_data($user);
|
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.
|
// Trigger event.
|
||||||
\core\event\user_created::create_from_userid($user->id)->trigger();
|
\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
|
* @param string $confirmsecret
|
||||||
*/
|
*/
|
||||||
function user_confirm($username, $confirmsecret) {
|
function user_confirm($username, $confirmsecret) {
|
||||||
global $DB;
|
global $DB, $SESSION;
|
||||||
$user = get_complete_user_data('username', $username);
|
$user = get_complete_user_data('username', $username);
|
||||||
|
|
||||||
if (!empty($user)) {
|
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
|
} else if ($user->secret == $confirmsecret) { // They have provided the secret key to get in
|
||||||
$DB->set_field("user", "confirmed", 1, array("id"=>$user->id));
|
$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;
|
return AUTH_CONFIRM_OK;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue