[ Index ] |
PHP Cross Reference of Joomla 4.2.2 documentation |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Joomla! Content Management System 5 * 6 * @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org> 7 * @license GNU General Public License version 2 or later; see LICENSE 8 */ 9 10 namespace Joomla\CMS\Event\MultiFactor; 11 12 use DomainException; 13 use Joomla\CMS\Event\AbstractImmutableEvent; 14 use Joomla\CMS\Event\Result\ResultAware; 15 use Joomla\CMS\Event\Result\ResultAwareInterface; 16 use Joomla\CMS\Event\Result\ResultTypeBooleanAware; 17 use Joomla\CMS\User\User; 18 use Joomla\Component\Users\Administrator\Table\MfaTable; 19 20 // phpcs:disable PSR1.Files.SideEffects 21 \defined('JPATH_PLATFORM') or die; 22 // phpcs:enable PSR1.Files.SideEffects 23 24 /** 25 * Concrete Event class for the onUserMultifactorValidate event 26 * 27 * @since 4.2.0 28 */ 29 class Validate extends AbstractImmutableEvent implements ResultAwareInterface 30 { 31 use ResultAware; 32 use ResultTypeBooleanAware; 33 34 /** 35 * Public constructor 36 * 37 * @param MfaTable $record The MFA record to validate against 38 * @param User $user The user currently logged into the site 39 * @param string $code The MFA code we are validating 40 * 41 * @since 4.2.0 42 */ 43 public function __construct(MfaTable $record, User $user, string $code) 44 { 45 parent::__construct( 46 'onUserMultifactorValidate', 47 [ 48 'record' => $record, 49 'user' => $user, 50 'code' => $code, 51 ] 52 ); 53 } 54 55 /** 56 * Validate the value of the 'record' named parameter 57 * 58 * @param MfaTable $value The value to validate 59 * 60 * @return MfaTable 61 * @since 4.2.0 62 */ 63 public function setRecord(MfaTable $value): MfaTable 64 { 65 if (empty($value)) { 66 throw new DomainException(sprintf('Argument \'record\' of event %s must be a MfaTable object.', $this->name)); 67 } 68 69 return $value; 70 } 71 72 /** 73 * Validate the value of the 'user' named parameter 74 * 75 * @param User $value The value to validate 76 * 77 * @return User 78 * @since 4.2.0 79 */ 80 public function setUser(User $value): User 81 { 82 if (empty($value) || ($value->id <= 0) || ($value->guest == 1)) { 83 throw new DomainException(sprintf('Argument \'user\' of event %s must be a non-guest User object.', $this->name)); 84 } 85 86 return $value; 87 } 88 89 /** 90 * Validate the value of the 'code' named parameter 91 * 92 * @param string|null $value The value to validate 93 * 94 * @return string|null 95 * @since 4.2.0 96 */ 97 public function setCode(?string $value): ?string 98 { 99 // No validation necessary, the type check in the method options is enough 100 return $value; 101 } 102 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Wed Sep 7 05:41:13 2022 | Chilli.vc Blog - For Webmaster,Blog-Writer,System Admin and Domainer |