dbnschools / moodle-theme_fordson

Theme for Moodle 3.3+
42 stars 40 forks source link

Error logging in as guest #58

Closed izendegi closed 5 years ago

izendegi commented 5 years ago

Hi,

I'm trying to enable guest access in a Moodle site following the docs 1 in a Moodle 3.6.1 with Fordson v3.6 release 1.1, but when I click on the 'Log in as guest' button it throws back a "Invalid login, please try again" message.

Changing the theme to Boost the button works as expected, so I guess it is something related to Fordson.

I've tried both the standard login and the custom Fordson login (showcustomlogin), and the error happens anyway.

dbnschools commented 5 years ago

Good find! This is a miss from when Moodle started requiring a login token. We provided that in normal login fields but I missed it for guest. If you add this in Fordson/templates/core/loginform.template around line 167 replacing similar code:

{{#canloginasguest}}
                        <div class="mt-2">
                            <p>{{#str}}someallowguest{{/str}}</p>
                            <form action="{{loginurl}}" method="post" id="guestlogin">
                                <input type="hidden" name="logintoken" value="{{logintoken}}">
                                <input type="hidden" name="username" value="guest" />
                                <input type="hidden" name="password" value="guest" />
                                <button class="btn btn-secondary btn-block" type="submit">{{#str}}loginguest{{/str}}</button>
                            </form>
                        </div>
{{/canloginasguest}}
dbnschools commented 5 years ago

<input type="hidden" name="logintoken" value="{{logintoken}}"> This line was missing.

dbnschools commented 5 years ago

Fixed in Version 1.2 for Moodle 3.6

izendegi commented 5 years ago

Hi,

I've tested it and realized that same change should be also done around line 275.

Once done that it worked like a charm!