From 1c8f115935f8e24b0d4da8c60c49e3c912651351 Mon Sep 17 00:00:00 2001 From: Dmitrii Metelkin Date: Sat, 27 Aug 2016 15:58:09 +1000 Subject: [PATCH] Change user key manager interface to abstract key validation --- classes/userkey_manager_interface.php | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/classes/userkey_manager_interface.php b/classes/userkey_manager_interface.php index 1e83b18..e9762f4 100644 --- a/classes/userkey_manager_interface.php +++ b/classes/userkey_manager_interface.php @@ -33,13 +33,29 @@ interface userkey_manager_interface { /** * Create a user key. * + * @param int $userid User ID. + * @param null|array $allowedips A list of allowed ips for this key. + * * @return string Generated key. */ - public function create_key(); + public function create_key($userid, $allowedips = null); /** - * Delete a user key. + * Delete all keys for a specific user. + * + * @param int $userid User ID. */ - public function delete_key(); + public function delete_keys($userid); + + /** + * Validates key and returns key data object if valid. + * + * @param string $keyvalue Key value. + * + * @return object Key object including userid property. + * + * @throws \moodle_exception If provided key is not valid. + */ + public function validate_key($keyvalue); } \ No newline at end of file