. /** * Event when one-time password is generated. * * @package auth_emailotp * @copyright 2020 Pawel Suwinski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace auth_emailotp\event; defined('MOODLE_INTERNAL') || die(); /** * Event when one-time password is generated. * * @package auth_emailotp * @copyright 2020 Pawel Suwinski * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class otp_generated extends \core\event\base { protected static $crud = 'c'; /** * {@inheritdoc} */ protected function init() { $this->data['crud'] = static::$crud; $this->data['edulevel'] = self::LEVEL_OTHER; $this->context = \context_system::instance(); } /** * {@inheritdoc} */ public static function get_name() { return get_string('eventotp'.substr(static::class, strrpos(static::class, '_') + 1), 'auth_emailotp'); } /** * {@inheritdoc} */ public function get_description() { return sprintf('Password %s for \'%s\'', $this->action, $this->other['email']); } /** * {@inheritdoc} */ protected function get_legacy_logdata() { return array(SITEID, 'auth_emailotp', $this->action, '', $this->other['email']); } /** * Custom validation. * * @throws \coding_exception */ protected function validate_data() { parent::validate_data(); if (!isset($this->other['email'])) { throw new \coding_exception('The \'email\' value must be set in other.'); } } public static function get_other_mapping() { return false; } }