Merge branch 'MDL-53047-login-anchor' of https://github.com/brendanheywood/moodle

This commit is contained in:
Andrew Nicols 2016-03-08 13:15:00 +08:00
commit 94d4d0179a
2 changed files with 12 additions and 0 deletions

View File

@ -37,6 +37,7 @@ redirect_if_major_upgrade_required();
$testsession = optional_param('testsession', 0, PARAM_INT); // test session works properly
$cancel = optional_param('cancel', 0, PARAM_BOOL); // redirect to frontpage, needed for loginhttps
$anchor = optional_param('anchor', '', PARAM_RAW); // Used to restore hash anchor to wantsurl.
if ($cancel) {
redirect(new moodle_url('/'));
@ -120,6 +121,15 @@ if ($user !== false or $frm !== false or $errormsg !== '') {
$frm = data_submitted();
}
// Restore the #anchor to the original wantsurl. Note that this
// will only work for internal auth plugins, SSO plugins such as
// SAML / CAS / OIDC will have to handle this correctly directly.
if ($anchor && isset($SESSION->wantsurl) && strpos($SESSION->wantsurl, '#') === false) {
$wantsurl = new moodle_url($SESSION->wantsurl);
$wantsurl->set_anchor(substr($anchor, 1));
$SESSION->wantsurl = $wantsurl->out();
}
/// Check if the user has actually submitted login data to us
if ($frm and isset($frm->username)) { // Login WITH cookies

View File

@ -53,6 +53,8 @@ if (empty($CFG->authloginviaemail)) {
</div>
<?php } ?>
<div class="clearer"><!-- --></div>
<input id="anchor" type="hidden" name="anchor" value="" />
<script>document.getElementById('anchor').value = location.hash</script>
<input type="submit" id="loginbtn" value="<?php print_string("login") ?>" />
<div class="forgetpass"><a href="forgot_password.php"><?php print_string("forgotten") ?></a></div>
</form>