by Daniel Miranda.
You should use a nologin as base.
The methods you need to implement are:
// Verify if user exists
$is_user = $DB->get_record('user', array('uid'));
if (!$is_user) {
$is_user = create_user_record($uid, $password, $this->authtype);
}
if ($is_user) {
$USER = get_complete_user_data('username', $is_user->username);
} else {
$this->error_page(get_string('error_create_user', self::COMPONENT_NAME));
}
public function do_login($urltogo) {
global $USER, $CFG;
complete_user_login($USER);
$USER->loggedin = true;
$USER->site = $CFG->wwwroot;
set_moodle_cookie($USER->username);
/**
* If we are not on the page we want, then redirect to it.
*/
if (qualified_me() !== $urltogo) {
redirect($urltogo);
exit;
}
}
try to read the auth.php from my saml2 auth plugin and understand the procedure to authenticate a user