1 <?php 2 // This file is part of Moodle - http://moodle.org/ 3 // 4 // Moodle is free software: you can redistribute it and/or modify 5 // it under the terms of the GNU General Public License as published by 6 // the Free Software Foundation, either version 3 of the License, or 7 // (at your option) any later version. 8 // 9 // Moodle is distributed in the hope that it will be useful, 10 // but WITHOUT ANY WARRANTY; without even the implied warranty of 11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 // GNU General Public License for more details. 13 // 14 // You should have received a copy of the GNU General Public License 15 // along with Moodle. If not, see <http://www.gnu.org/licenses/>. 16 17 namespace factor_email\event; 18 19 use stdClass; 20 21 /** 22 * Event for when a user receives an unauthorised email from MFA. 23 * 24 * @property-read array $other { 25 * Extra information about event. 26 * } 27 * 28 * @package factor_email 29 * @author Peter Burnett <peterburnett@catalyst-au.net> 30 * @copyright Catalyst IT 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class unauth_email extends \core\event\base { 34 35 /** 36 * Create instance of event. 37 * 38 * @param stdClass $user the User object of the User who passed all MFA factor checks. 39 * @param string $ip the ip address the unauthorised email came from. 40 * @param string $useragent the browser fingerpring the unauthorised email came from. 41 * 42 * @return \core\event\base the user_passed_mfa event 43 * 44 * @throws \coding_exception 45 */ 46 public static function unauth_email_event(stdClass $user, string $ip, string $useragent): \core\event\base { 47 48 $data = [ 49 'relateduserid' => null, 50 'context' => \context_user::instance($user->id), 51 'other' => [ 52 'userid' => $user->id, 53 'ip' => $ip, 54 'useragent' => $useragent, 55 ], 56 ]; 57 58 return self::create($data); 59 } 60 61 /** 62 * Init method. 63 * 64 * @return void 65 */ 66 protected function init(): void { 67 $this->data['crud'] = 'r'; 68 $this->data['edulevel'] = self::LEVEL_OTHER; 69 } 70 71 /** 72 * Returns description of what happened. 73 * 74 * @return string 75 */ 76 public function get_description(): string { 77 $data = new stdClass(); 78 $data->userid = $this->other['userid']; 79 $data->ip = $this->other['ip']; 80 $data->useragent = $this->other['useragent']; 81 return get_string('unauthloginattempt', 'factor_email', $data); 82 } 83 84 /** 85 * Return localised event name. 86 * 87 * @return string 88 * @throws \coding_exception 89 */ 90 public static function get_name(): string { 91 return get_string('event:unauthemail', 'factor_email'); 92 } 93 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body