Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.0.x will end 8 May 2023 (12 months).
  • Bug fixes for security issues in 4.0.x will end 13 November 2023 (18 months).
  • PHP version: minimum PHP 7.3.0 Note: the minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is also supported.

Differences Between: [Versions 310 and 400] [Versions 39 and 400] [Versions 400 and 401] [Versions 400 and 402] [Versions 400 and 403]

Class for loading/storing oauth2 linked logins from the DB.

Copyright: 2017 Damyon Wiese
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 407 lines (14 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class


Class: api  - X-Ref

Static list of api methods for auth oauth2 configuration.

clean_orphaned_linked_logins($issuerid = false)   X-Ref
Remove all linked logins that are using issuers that have been deleted.

return: boolean
param: int $issuerid The issuer id of the issuer to check, or false to check all (defaults to all)

get_linked_logins($userid = false)   X-Ref
List linked logins

Requires auth/oauth2:managelinkedlogins capability at the user context.

return: boolean
param: int $userid (defaults to $USER->id)

match_username_to_user($username, $issuer)   X-Ref
See if there is a match for this username and issuer in the linked_login table.

return: stdClass User record if found.
param: string $username as returned from an oauth client.
param: \core\oauth2\issuer $issuer

link_login($userinfo, $issuer, $userid = false, $skippermissions = false)   X-Ref
Link a login to this account.

Requires auth/oauth2:managelinkedlogins capability at the user context.

return: bool
param: array $userinfo as returned from an oauth client.
param: \core\oauth2\issuer $issuer
param: int $userid (defaults to $USER->id)
param: bool $skippermissions During signup we need to set this before the user is setup for capability checks.

send_confirm_link_login_email($userinfo, $issuer, $userid)   X-Ref
Send an email with a link to confirm linking this account.

return: bool
param: array $userinfo as returned from an oauth client.
param: \core\oauth2\issuer $issuer
param: int $userid (defaults to $USER->id)

confirm_link_login($userid, $username, $issuerid, $token)   X-Ref
Look for a waiting confirmation token, and if we find a match - confirm it.

return: boolean True if we linked.
param: int $userid
param: string $username
param: int $issuerid
param: string $token

create_new_confirmed_account($userinfo, $issuer)   X-Ref
Create an account with a linked login that is already confirmed.

return: bool
param: array $userinfo as returned from an oauth client.
param: \core\oauth2\issuer $issuer

send_confirm_account_email($userinfo, $issuer)   X-Ref
Send an email with a link to confirm creating this account.

return: bool
param: array $userinfo as returned from an oauth client.
param: \core\oauth2\issuer $issuer
param: int $userid (defaults to $USER->id)

delete_linked_login($linkedloginid)   X-Ref
Delete linked login

Requires auth/oauth2:managelinkedlogins capability at the user context.

return: boolean
param: int $linkedloginid

user_deleted(\core\event\user_deleted $event)   X-Ref
Delete linked logins for a user.

return: boolean
param: \core\event\user_deleted $event

is_enabled()   X-Ref
Is the plugin enabled.

return: bool