-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improvement: Add a side entrance login page for local logins if the l…
- Loading branch information
Showing
8 changed files
with
220 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Theme Boost Union - Local login page | ||
* | ||
* This file is copied, reduced and modified from /login/index.php. | ||
* | ||
* @package theme_boost_union | ||
* @copyright 2023 Alexander Bias <[email protected]> | ||
* based on code 1999 onwards Martin Dougiamas | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
// Include config.php. | ||
// @codingStandardsIgnoreStart | ||
// Let codechecker ignore the next line because otherwise it would complain about a missing login check | ||
// after requiring config.php which is really not needed. | ||
require(__DIR__.'/../../config.php'); | ||
// @codingStandardsIgnoreEnd | ||
|
||
// Require the necessary libraries. | ||
require_once($CFG->dirroot.'/lib/authlib.php'); | ||
require_once($CFG->dirroot.'/theme/boost_union/lib.php'); | ||
|
||
// Set page URL. | ||
$PAGE->set_url('/theme/boost_union/locallogin.php'); | ||
|
||
// Set page layout. | ||
$PAGE->set_pagelayout('login'); | ||
|
||
// Set page context. | ||
$PAGE->set_context(context_system::instance()); | ||
|
||
// Get theme config. | ||
$config = get_config('theme_boost_union'); | ||
|
||
// If the local login is not disabled, we just show a short friendly warning page and are done. | ||
if ($config->loginlocalloginenable != THEME_BOOST_UNION_SETTING_SELECT_NO) { | ||
echo $OUTPUT->header(); | ||
$loginurl = new moodle_url('/login/index.php'); | ||
$notification = new \core\output\notification( | ||
get_string('loginlocalloginlocalnotdisabled', 'theme_boost_union', ['url' => $loginurl]), | ||
\core\output\notification::NOTIFY_INFO); | ||
$notification->set_show_closebutton(false); | ||
echo $OUTPUT->render($notification); | ||
echo $OUTPUT->footer(); | ||
die; | ||
} | ||
|
||
// If the user is already logged in or is a guest user. | ||
if (isloggedin() || isguestuser()) { | ||
// We just redirect him to the standard login page to handle this case. | ||
redirect('/login/index.php'); | ||
} | ||
|
||
// Set page title. | ||
$PAGE->set_title(get_string('loginsite')); | ||
|
||
// Start page output. | ||
echo $OUTPUT->header(); | ||
|
||
// Prepare the local login form. | ||
$templatecontext = []; | ||
$templatecontext['loginurl'] = new moodle_url('/login/index.php'); | ||
$templatecontext['logintoken'] = \core\session\manager::get_login_token(); | ||
|
||
// Output the local login form. | ||
echo $OUTPUT->render_from_template('theme_boost_union/localloginform', $templatecontext); | ||
|
||
// Finish page. | ||
echo $OUTPUT->footer(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{{! | ||
This file is part of Moodle - http://moodle.org/ | ||
Moodle is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
Moodle is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
}} | ||
{{! | ||
@template theme_boost_union/localloginform | ||
Boost Union template for outputting the local login form on the local login page. | ||
This is a limited and modified version of core/loginform. | ||
Context variables required for this template: | ||
* loginurl - Login url, | ||
* logintoken - Random token to protect login request., | ||
Example context (json): | ||
{ | ||
"loginurl": "http://localhost/stable_master/login/index.php", | ||
"logintoken": "randomstring", | ||
} | ||
}} | ||
|
||
<div class="loginform"> | ||
<h1 class="login-heading mb-4">{{#str}}loginlocalloginformhead, theme_boost_union{{/str}}</h1> | ||
<form class="login-form" action="{{loginurl}}" method="post" id="login"> | ||
<input type="hidden" name="logintoken" value="{{logintoken}}"> | ||
<div class="login-form-username form-group"> | ||
<label for="username" class="sr-only">{{#str}}username{{/str}}</label> | ||
<input type="text" name="username" id="username" {{! | ||
!}}class="form-control form-control-lg"{{! | ||
!}}placeholder="{{#cleanstr}}username{{/cleanstr}}"> | ||
</div> | ||
<div class="login-form-password form-group"> | ||
<label for="password" class="sr-only">{{#str}} password {{/str}}</label> | ||
<input type="password" name="password" id="password" value="" {{! | ||
!}}class="form-control form-control-lg" {{! | ||
!}}placeholder="{{#cleanstr}}password{{/cleanstr}}"> | ||
</div> | ||
<div class="login-form-submit form-group"> | ||
<button class="btn btn-primary btn-lg" type="submit" id="loginbtn">{{#str}}login{{/str}}</button> | ||
</div> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<?php | ||
// This file is part of Moodle - http://moodle.org/ | ||
// | ||
// Moodle is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Moodle is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. | ||
|
||
/** | ||
* Theme Boost Union - Custom Behat rules for the 'Look' settings | ||
* | ||
* @package theme_boost_union | ||
* @copyright 2023 Alexander Bias <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
require_once(__DIR__ . '/../../../../lib/behat/behat_base.php'); | ||
|
||
/** | ||
* Class behat_theme_boost_union_base_look | ||
* | ||
* @package theme_boost_union | ||
* @copyright 2023 Alexander Bias <[email protected]> | ||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
class behat_theme_boost_union_base_look extends behat_base { | ||
/** | ||
* Open the local login page. | ||
* | ||
* @Given /^I am on local login page$/ | ||
*/ | ||
public function i_am_on_local_login_page() { | ||
$this->execute('behat_general::i_visit', ['/theme/boost_union/locallogin.php']); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters