Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

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

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.

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

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

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

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

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

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

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.

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.
return: bool

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

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

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

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

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

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

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

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

delete_linked_login($linkedloginid)   X-Ref
Delete linked login

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

param: int $linkedloginid
return: boolean

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

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

is_enabled()   X-Ref
Is the plugin enabled.

return: bool