Customising the authentication choice page when using multiple authentication methods

Customising the authentication choice page when using multiple authentication methods

by Doc Hallam -
Number of replies: 3

Hi,

We have a Moodle site that we have recently upgraded, and as part of the upgrade we implemented both CAS and Manual Accounts. This is all working fine.

When users attempt to login they are presented with the standard authentication choice page

We would like to modify this page to provide clearer instructions to users, something along the lines of

We have tried to insert this new page between the Moodle site front page and the authentication page - basically replacing moodle/login/index.php with the new page which then calls the original index.php (renamed to index_real.php) passing CAS or NOCAS depending on which link is clicked on the new page, i.e.

moodle/login/index_real.php?authCAS=CAS

moodle/login/index_realphp?authCAS=NOCAS

This seems to break things big time.

 

We considered using an alternative login page URL in the authentication settings, but that isn't what we're really trying to do here. We also tried adding instructions in the authentication settings but these are only displayed for non-CAS longins and after the authentication choice is presented.

The best we have managed so far is to modify the choice text on the two links, but we'd really like the new page above if possible.

Has anyone managed to do customize the authentication choice page along these lines? Any ideas would be very much appreciated.

We're running Moodle 2.6+ (Build: 20131129)

Thanks,

Dochallam

Average of ratings: -
In reply to Doc Hallam

Re: Customising the authentication choice page when using multiple authentication methods

by Doc Hallam -

Ah, since posting this we've found a solution that works so here's answering my own question!

There's a file under moodle/auth/cas called cas_form.html, which has default contents:

<div class="loginbox clearfix">
<div class="loginpanel">
<div>
<a href="<?php echo get_login_url() . '?authCAS=CAS';?>"><?php print_string('accesCAS', 'auth_cas');?></a>
</div>
<br/>
<div>
<a href="<?php echo get_login_url() . '?authCAS=NOCAS';?>"><?php print_string('accesNOCAS', 'auth_cas');?></a>
</div>
</div>
</div>

I saved a copy of the original cas_form.html file and replaced it with our custom HTML file, replacing our simple links with those specified in the default cas_form.html file, namely

<a href="<?php echo get_login_url() . '?authCAS=CAS';?>"><?php print_string('accesCAS', 'auth_cas');?></a>

for the CAS logins and

<a href="<?php echo get_login_url() . '?authCAS=NOCAS';?>"><?php print_string('accesNOCAS', 'auth_cas');?>

for the non-CAS logins (i.e. the manually created accounts). I would think you could use pretty much whatever HTML you liked in the cas_form.html, and provided you use the CAS and NOCAS href's then it would work.

Note that there's also a file moodle/auth/cas/lang/en/auth_cas.php where you can modify the text used for the CAS and NOCAS links; these are the defaults

$string['accesCAS'] = 'CAS users';

$string['accesNOCAS'] = 'other users';

Hope that helps someone, and apologies if it's a trivial solution that I should have known about - I'm quite new to Moodle admin.

Cheers,

dochallam

In reply to Doc Hallam

Re: Customising the authentication choice page when using multiple authentication methods

by Tiffany Backers -

Hi Doc,


We had the exact same problem and your solution helped us hugely!


Thank you for sharing!

In reply to Doc Hallam

Ynt: Re: Customising the authentication choice page when using multiple authentication methods

by Arda Cetin -

Thank you for sharing! It's very helpful.