@@ -27,37 +27,37 @@ |
||
| 27 | 27 | use OCP\Federation\ICloudFederationShare; |
| 28 | 28 | |
| 29 | 29 | class CloudFederationFactory implements ICloudFederationFactory { |
| 30 | - /** |
|
| 31 | - * get a CloudFederationShare Object to prepare a share you want to send |
|
| 32 | - * |
|
| 33 | - * @param string $shareWith |
|
| 34 | - * @param string $name resource name (e.g. document.odt) |
|
| 35 | - * @param string $description share description (optional) |
|
| 36 | - * @param string $providerId resource UID on the provider side |
|
| 37 | - * @param string $owner provider specific UID of the user who owns the resource |
|
| 38 | - * @param string $ownerDisplayName display name of the user who shared the item |
|
| 39 | - * @param string $sharedBy provider specific UID of the user who shared the resource |
|
| 40 | - * @param string $sharedByDisplayName display name of the user who shared the resource |
|
| 41 | - * @param string $sharedSecret used to authenticate requests across servers |
|
| 42 | - * @param string $shareType ('group' or 'user' share) |
|
| 43 | - * @param $resourceType ('file', 'calendar',...) |
|
| 44 | - * @return ICloudFederationShare |
|
| 45 | - * |
|
| 46 | - * @since 14.0.0 |
|
| 47 | - */ |
|
| 48 | - public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { |
|
| 49 | - return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); |
|
| 50 | - } |
|
| 30 | + /** |
|
| 31 | + * get a CloudFederationShare Object to prepare a share you want to send |
|
| 32 | + * |
|
| 33 | + * @param string $shareWith |
|
| 34 | + * @param string $name resource name (e.g. document.odt) |
|
| 35 | + * @param string $description share description (optional) |
|
| 36 | + * @param string $providerId resource UID on the provider side |
|
| 37 | + * @param string $owner provider specific UID of the user who owns the resource |
|
| 38 | + * @param string $ownerDisplayName display name of the user who shared the item |
|
| 39 | + * @param string $sharedBy provider specific UID of the user who shared the resource |
|
| 40 | + * @param string $sharedByDisplayName display name of the user who shared the resource |
|
| 41 | + * @param string $sharedSecret used to authenticate requests across servers |
|
| 42 | + * @param string $shareType ('group' or 'user' share) |
|
| 43 | + * @param $resourceType ('file', 'calendar',...) |
|
| 44 | + * @return ICloudFederationShare |
|
| 45 | + * |
|
| 46 | + * @since 14.0.0 |
|
| 47 | + */ |
|
| 48 | + public function getCloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $sharedSecret, $shareType, $resourceType) { |
|
| 49 | + return new CloudFederationShare($shareWith, $name, $description, $providerId, $owner, $ownerDisplayName, $sharedBy, $sharedByDisplayName, $shareType, $resourceType, $sharedSecret); |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * get a Cloud FederationNotification object to prepare a notification you |
|
| 54 | - * want to send |
|
| 55 | - * |
|
| 56 | - * @return ICloudFederationNotification |
|
| 57 | - * |
|
| 58 | - * @since 14.0.0 |
|
| 59 | - */ |
|
| 60 | - public function getCloudFederationNotification() { |
|
| 61 | - return new CloudFederationNotification(); |
|
| 62 | - } |
|
| 52 | + /** |
|
| 53 | + * get a Cloud FederationNotification object to prepare a notification you |
|
| 54 | + * want to send |
|
| 55 | + * |
|
| 56 | + * @return ICloudFederationNotification |
|
| 57 | + * |
|
| 58 | + * @since 14.0.0 |
|
| 59 | + */ |
|
| 60 | + public function getCloudFederationNotification() { |
|
| 61 | + return new CloudFederationNotification(); |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -33,17 +33,17 @@ |
||
| 33 | 33 | * @method getClass(): string |
| 34 | 34 | */ |
| 35 | 35 | class AuthorizedGroup extends Entity implements \JsonSerializable { |
| 36 | - /** @var string $group_id */ |
|
| 37 | - protected $groupId; |
|
| 36 | + /** @var string $group_id */ |
|
| 37 | + protected $groupId; |
|
| 38 | 38 | |
| 39 | - /** @var string $class */ |
|
| 40 | - protected $class; |
|
| 39 | + /** @var string $class */ |
|
| 40 | + protected $class; |
|
| 41 | 41 | |
| 42 | - public function jsonSerialize(): array { |
|
| 43 | - return [ |
|
| 44 | - 'id' => $this->id, |
|
| 45 | - 'group_id' => $this->groupId, |
|
| 46 | - 'class' => $this->class |
|
| 47 | - ]; |
|
| 48 | - } |
|
| 42 | + public function jsonSerialize(): array { |
|
| 43 | + return [ |
|
| 44 | + 'id' => $this->id, |
|
| 45 | + 'group_id' => $this->groupId, |
|
| 46 | + 'class' => $this->class |
|
| 47 | + ]; |
|
| 48 | + } |
|
| 49 | 49 | } |
@@ -31,28 +31,28 @@ |
||
| 31 | 31 | use OCP\EventDispatcher\Event; |
| 32 | 32 | |
| 33 | 33 | class BroadcastEvent extends Event implements IBroadcastEvent { |
| 34 | - /** @var ABroadcastedEvent */ |
|
| 35 | - private $event; |
|
| 34 | + /** @var ABroadcastedEvent */ |
|
| 35 | + private $event; |
|
| 36 | 36 | |
| 37 | - public function __construct(ABroadcastedEvent $event) { |
|
| 38 | - parent::__construct(); |
|
| 37 | + public function __construct(ABroadcastedEvent $event) { |
|
| 38 | + parent::__construct(); |
|
| 39 | 39 | |
| 40 | - $this->event = $event; |
|
| 41 | - } |
|
| 40 | + $this->event = $event; |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function getName(): string { |
|
| 44 | - return $this->event->broadcastAs(); |
|
| 45 | - } |
|
| 43 | + public function getName(): string { |
|
| 44 | + return $this->event->broadcastAs(); |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - public function getUids(): array { |
|
| 48 | - return $this->event->getUids(); |
|
| 49 | - } |
|
| 47 | + public function getUids(): array { |
|
| 48 | + return $this->event->getUids(); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - public function getPayload(): JsonSerializable { |
|
| 52 | - return $this->event; |
|
| 53 | - } |
|
| 51 | + public function getPayload(): JsonSerializable { |
|
| 52 | + return $this->event; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function setBroadcasted(): void { |
|
| 56 | - $this->event->setBroadcasted(); |
|
| 57 | - } |
|
| 55 | + public function setBroadcasted(): void { |
|
| 56 | + $this->event->setBroadcasted(); |
|
| 57 | + } |
|
| 58 | 58 | } |
@@ -34,38 +34,38 @@ |
||
| 34 | 34 | * To be used when locking is disabled. |
| 35 | 35 | */ |
| 36 | 36 | class NoopLockingProvider implements ILockingProvider { |
| 37 | - /** |
|
| 38 | - * {@inheritdoc} |
|
| 39 | - */ |
|
| 40 | - public function isLocked(string $path, int $type): bool { |
|
| 41 | - return false; |
|
| 42 | - } |
|
| 37 | + /** |
|
| 38 | + * {@inheritdoc} |
|
| 39 | + */ |
|
| 40 | + public function isLocked(string $path, int $type): bool { |
|
| 41 | + return false; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * {@inheritdoc} |
|
| 46 | - */ |
|
| 47 | - public function acquireLock(string $path, int $type, ?string $readablePath = null): void { |
|
| 48 | - // do nothing |
|
| 49 | - } |
|
| 44 | + /** |
|
| 45 | + * {@inheritdoc} |
|
| 46 | + */ |
|
| 47 | + public function acquireLock(string $path, int $type, ?string $readablePath = null): void { |
|
| 48 | + // do nothing |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * {@inheritdoc} |
|
| 53 | - */ |
|
| 54 | - public function releaseLock(string $path, int $type): void { |
|
| 55 | - // do nothing |
|
| 56 | - } |
|
| 51 | + /** |
|
| 52 | + * {@inheritdoc} |
|
| 53 | + */ |
|
| 54 | + public function releaseLock(string $path, int $type): void { |
|
| 55 | + // do nothing |
|
| 56 | + } |
|
| 57 | 57 | |
| 58 | - /**1 |
|
| 58 | + /**1 |
|
| 59 | 59 | * {@inheritdoc} |
| 60 | 60 | */ |
| 61 | - public function releaseAll(): void { |
|
| 62 | - // do nothing |
|
| 63 | - } |
|
| 61 | + public function releaseAll(): void { |
|
| 62 | + // do nothing |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * {@inheritdoc} |
|
| 67 | - */ |
|
| 68 | - public function changeLock(string $path, int $targetType): void { |
|
| 69 | - // do nothing |
|
| 70 | - } |
|
| 65 | + /** |
|
| 66 | + * {@inheritdoc} |
|
| 67 | + */ |
|
| 68 | + public function changeLock(string $path, int $targetType): void { |
|
| 69 | + // do nothing |
|
| 70 | + } |
|
| 71 | 71 | } |
@@ -27,8 +27,8 @@ |
||
| 27 | 27 | namespace OC\Authentication\Token; |
| 28 | 28 | |
| 29 | 29 | interface IWipeableToken extends IToken { |
| 30 | - /** |
|
| 31 | - * Mark the token for remote wipe |
|
| 32 | - */ |
|
| 33 | - public function wipe(): void; |
|
| 30 | + /** |
|
| 31 | + * Mark the token for remote wipe |
|
| 32 | + */ |
|
| 33 | + public function wipe(): void; |
|
| 34 | 34 | } |
@@ -33,62 +33,62 @@ |
||
| 33 | 33 | use OCP\IUser; |
| 34 | 34 | |
| 35 | 35 | class ProviderManager { |
| 36 | - /** @var ProviderLoader */ |
|
| 37 | - private $providerLoader; |
|
| 36 | + /** @var ProviderLoader */ |
|
| 37 | + private $providerLoader; |
|
| 38 | 38 | |
| 39 | - /** @var IRegistry */ |
|
| 40 | - private $providerRegistry; |
|
| 39 | + /** @var IRegistry */ |
|
| 40 | + private $providerRegistry; |
|
| 41 | 41 | |
| 42 | - public function __construct(ProviderLoader $providerLoader, IRegistry $providerRegistry) { |
|
| 43 | - $this->providerLoader = $providerLoader; |
|
| 44 | - $this->providerRegistry = $providerRegistry; |
|
| 45 | - } |
|
| 42 | + public function __construct(ProviderLoader $providerLoader, IRegistry $providerRegistry) { |
|
| 43 | + $this->providerLoader = $providerLoader; |
|
| 44 | + $this->providerRegistry = $providerRegistry; |
|
| 45 | + } |
|
| 46 | 46 | |
| 47 | - private function getProvider(string $providerId, IUser $user): IProvider { |
|
| 48 | - $providers = $this->providerLoader->getProviders($user); |
|
| 47 | + private function getProvider(string $providerId, IUser $user): IProvider { |
|
| 48 | + $providers = $this->providerLoader->getProviders($user); |
|
| 49 | 49 | |
| 50 | - if (!isset($providers[$providerId])) { |
|
| 51 | - throw new InvalidProviderException($providerId); |
|
| 52 | - } |
|
| 50 | + if (!isset($providers[$providerId])) { |
|
| 51 | + throw new InvalidProviderException($providerId); |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return $providers[$providerId]; |
|
| 55 | - } |
|
| 54 | + return $providers[$providerId]; |
|
| 55 | + } |
|
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * Try to enable the provider with the given id for the given user |
|
| 59 | - * |
|
| 60 | - * @param IUser $user |
|
| 61 | - * |
|
| 62 | - * @return bool whether the provider supports this operation |
|
| 63 | - */ |
|
| 64 | - public function tryEnableProviderFor(string $providerId, IUser $user): bool { |
|
| 65 | - $provider = $this->getProvider($providerId, $user); |
|
| 57 | + /** |
|
| 58 | + * Try to enable the provider with the given id for the given user |
|
| 59 | + * |
|
| 60 | + * @param IUser $user |
|
| 61 | + * |
|
| 62 | + * @return bool whether the provider supports this operation |
|
| 63 | + */ |
|
| 64 | + public function tryEnableProviderFor(string $providerId, IUser $user): bool { |
|
| 65 | + $provider = $this->getProvider($providerId, $user); |
|
| 66 | 66 | |
| 67 | - if ($provider instanceof IActivatableByAdmin) { |
|
| 68 | - $provider->enableFor($user); |
|
| 69 | - $this->providerRegistry->enableProviderFor($provider, $user); |
|
| 70 | - return true; |
|
| 71 | - } else { |
|
| 72 | - return false; |
|
| 73 | - } |
|
| 74 | - } |
|
| 67 | + if ($provider instanceof IActivatableByAdmin) { |
|
| 68 | + $provider->enableFor($user); |
|
| 69 | + $this->providerRegistry->enableProviderFor($provider, $user); |
|
| 70 | + return true; |
|
| 71 | + } else { |
|
| 72 | + return false; |
|
| 73 | + } |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - /** |
|
| 77 | - * Try to disable the provider with the given id for the given user |
|
| 78 | - * |
|
| 79 | - * @param IUser $user |
|
| 80 | - * |
|
| 81 | - * @return bool whether the provider supports this operation |
|
| 82 | - */ |
|
| 83 | - public function tryDisableProviderFor(string $providerId, IUser $user): bool { |
|
| 84 | - $provider = $this->getProvider($providerId, $user); |
|
| 76 | + /** |
|
| 77 | + * Try to disable the provider with the given id for the given user |
|
| 78 | + * |
|
| 79 | + * @param IUser $user |
|
| 80 | + * |
|
| 81 | + * @return bool whether the provider supports this operation |
|
| 82 | + */ |
|
| 83 | + public function tryDisableProviderFor(string $providerId, IUser $user): bool { |
|
| 84 | + $provider = $this->getProvider($providerId, $user); |
|
| 85 | 85 | |
| 86 | - if ($provider instanceof IDeactivatableByAdmin) { |
|
| 87 | - $provider->disableFor($user); |
|
| 88 | - $this->providerRegistry->disableProviderFor($provider, $user); |
|
| 89 | - return true; |
|
| 90 | - } else { |
|
| 91 | - return false; |
|
| 92 | - } |
|
| 93 | - } |
|
| 86 | + if ($provider instanceof IDeactivatableByAdmin) { |
|
| 87 | + $provider->disableFor($user); |
|
| 88 | + $this->providerRegistry->disableProviderFor($provider, $user); |
|
| 89 | + return true; |
|
| 90 | + } else { |
|
| 91 | + return false; |
|
| 92 | + } |
|
| 93 | + } |
|
| 94 | 94 | } |
@@ -30,82 +30,82 @@ |
||
| 30 | 30 | use OCP\IUser; |
| 31 | 31 | |
| 32 | 32 | class MandatoryTwoFactor { |
| 33 | - /** @var IConfig */ |
|
| 34 | - private $config; |
|
| 33 | + /** @var IConfig */ |
|
| 34 | + private $config; |
|
| 35 | 35 | |
| 36 | - /** @var IGroupManager */ |
|
| 37 | - private $groupManager; |
|
| 36 | + /** @var IGroupManager */ |
|
| 37 | + private $groupManager; |
|
| 38 | 38 | |
| 39 | - public function __construct(IConfig $config, IGroupManager $groupManager) { |
|
| 40 | - $this->config = $config; |
|
| 41 | - $this->groupManager = $groupManager; |
|
| 42 | - } |
|
| 39 | + public function __construct(IConfig $config, IGroupManager $groupManager) { |
|
| 40 | + $this->config = $config; |
|
| 41 | + $this->groupManager = $groupManager; |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Get the state of enforced two-factor auth |
|
| 46 | - */ |
|
| 47 | - public function getState(): EnforcementState { |
|
| 48 | - return new EnforcementState( |
|
| 49 | - $this->config->getSystemValue('twofactor_enforced', 'false') === 'true', |
|
| 50 | - $this->config->getSystemValue('twofactor_enforced_groups', []), |
|
| 51 | - $this->config->getSystemValue('twofactor_enforced_excluded_groups', []) |
|
| 52 | - ); |
|
| 53 | - } |
|
| 44 | + /** |
|
| 45 | + * Get the state of enforced two-factor auth |
|
| 46 | + */ |
|
| 47 | + public function getState(): EnforcementState { |
|
| 48 | + return new EnforcementState( |
|
| 49 | + $this->config->getSystemValue('twofactor_enforced', 'false') === 'true', |
|
| 50 | + $this->config->getSystemValue('twofactor_enforced_groups', []), |
|
| 51 | + $this->config->getSystemValue('twofactor_enforced_excluded_groups', []) |
|
| 52 | + ); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Set the state of enforced two-factor auth |
|
| 57 | - */ |
|
| 58 | - public function setState(EnforcementState $state) { |
|
| 59 | - $this->config->setSystemValue('twofactor_enforced', $state->isEnforced() ? 'true' : 'false'); |
|
| 60 | - $this->config->setSystemValue('twofactor_enforced_groups', $state->getEnforcedGroups()); |
|
| 61 | - $this->config->setSystemValue('twofactor_enforced_excluded_groups', $state->getExcludedGroups()); |
|
| 62 | - } |
|
| 55 | + /** |
|
| 56 | + * Set the state of enforced two-factor auth |
|
| 57 | + */ |
|
| 58 | + public function setState(EnforcementState $state) { |
|
| 59 | + $this->config->setSystemValue('twofactor_enforced', $state->isEnforced() ? 'true' : 'false'); |
|
| 60 | + $this->config->setSystemValue('twofactor_enforced_groups', $state->getEnforcedGroups()); |
|
| 61 | + $this->config->setSystemValue('twofactor_enforced_excluded_groups', $state->getExcludedGroups()); |
|
| 62 | + } |
|
| 63 | 63 | |
| 64 | - /** |
|
| 65 | - * Check if two-factor auth is enforced for a specific user |
|
| 66 | - * |
|
| 67 | - * The admin(s) can enforce two-factor auth system-wide, for certain groups only |
|
| 68 | - * and also have the option to exclude users of certain groups. This method will |
|
| 69 | - * check their membership of those groups. |
|
| 70 | - * |
|
| 71 | - * @param IUser $user |
|
| 72 | - * |
|
| 73 | - * @return bool |
|
| 74 | - */ |
|
| 75 | - public function isEnforcedFor(IUser $user): bool { |
|
| 76 | - $state = $this->getState(); |
|
| 77 | - if (!$state->isEnforced()) { |
|
| 78 | - return false; |
|
| 79 | - } |
|
| 80 | - $uid = $user->getUID(); |
|
| 64 | + /** |
|
| 65 | + * Check if two-factor auth is enforced for a specific user |
|
| 66 | + * |
|
| 67 | + * The admin(s) can enforce two-factor auth system-wide, for certain groups only |
|
| 68 | + * and also have the option to exclude users of certain groups. This method will |
|
| 69 | + * check their membership of those groups. |
|
| 70 | + * |
|
| 71 | + * @param IUser $user |
|
| 72 | + * |
|
| 73 | + * @return bool |
|
| 74 | + */ |
|
| 75 | + public function isEnforcedFor(IUser $user): bool { |
|
| 76 | + $state = $this->getState(); |
|
| 77 | + if (!$state->isEnforced()) { |
|
| 78 | + return false; |
|
| 79 | + } |
|
| 80 | + $uid = $user->getUID(); |
|
| 81 | 81 | |
| 82 | - /* |
|
| 82 | + /* |
|
| 83 | 83 | * If there is a list of enforced groups, we only enforce 2FA for members of those groups. |
| 84 | 84 | * For all the other users it is not enforced (overruling the excluded groups list). |
| 85 | 85 | */ |
| 86 | - if (!empty($state->getEnforcedGroups())) { |
|
| 87 | - foreach ($state->getEnforcedGroups() as $group) { |
|
| 88 | - if ($this->groupManager->isInGroup($uid, $group)) { |
|
| 89 | - return true; |
|
| 90 | - } |
|
| 91 | - } |
|
| 92 | - // Not a member of any of these groups -> no 2FA enforced |
|
| 93 | - return false; |
|
| 94 | - } |
|
| 86 | + if (!empty($state->getEnforcedGroups())) { |
|
| 87 | + foreach ($state->getEnforcedGroups() as $group) { |
|
| 88 | + if ($this->groupManager->isInGroup($uid, $group)) { |
|
| 89 | + return true; |
|
| 90 | + } |
|
| 91 | + } |
|
| 92 | + // Not a member of any of these groups -> no 2FA enforced |
|
| 93 | + return false; |
|
| 94 | + } |
|
| 95 | 95 | |
| 96 | - /** |
|
| 97 | - * If the user is member of an excluded group, 2FA won't be enforced. |
|
| 98 | - */ |
|
| 99 | - foreach ($state->getExcludedGroups() as $group) { |
|
| 100 | - if ($this->groupManager->isInGroup($uid, $group)) { |
|
| 101 | - return false; |
|
| 102 | - } |
|
| 103 | - } |
|
| 96 | + /** |
|
| 97 | + * If the user is member of an excluded group, 2FA won't be enforced. |
|
| 98 | + */ |
|
| 99 | + foreach ($state->getExcludedGroups() as $group) { |
|
| 100 | + if ($this->groupManager->isInGroup($uid, $group)) { |
|
| 101 | + return false; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - /** |
|
| 106 | - * No enforced groups configured and user not member of an excluded groups, |
|
| 107 | - * so 2FA is enforced. |
|
| 108 | - */ |
|
| 109 | - return true; |
|
| 110 | - } |
|
| 105 | + /** |
|
| 106 | + * No enforced groups configured and user not member of an excluded groups, |
|
| 107 | + * so 2FA is enforced. |
|
| 108 | + */ |
|
| 109 | + return true; |
|
| 110 | + } |
|
| 111 | 111 | } |
@@ -29,15 +29,15 @@ |
||
| 29 | 29 | use OCP\EventDispatcher\Event; |
| 30 | 30 | |
| 31 | 31 | abstract class ARemoteWipeEvent extends Event { |
| 32 | - /** @var IToken */ |
|
| 33 | - private $token; |
|
| 32 | + /** @var IToken */ |
|
| 33 | + private $token; |
|
| 34 | 34 | |
| 35 | - public function __construct(IToken $token) { |
|
| 36 | - parent::__construct(); |
|
| 37 | - $this->token = $token; |
|
| 38 | - } |
|
| 35 | + public function __construct(IToken $token) { |
|
| 36 | + parent::__construct(); |
|
| 37 | + $this->token = $token; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - public function getToken(): IToken { |
|
| 41 | - return $this->token; |
|
| 42 | - } |
|
| 40 | + public function getToken(): IToken { |
|
| 41 | + return $this->token; |
|
| 42 | + } |
|
| 43 | 43 | } |
@@ -35,28 +35,28 @@ |
||
| 35 | 35 | * @template-implements IEventListener<\OCP\User\Events\PostLoginEvent> |
| 36 | 36 | */ |
| 37 | 37 | class UserLoggedInListener implements IEventListener { |
| 38 | - /** @var Manager */ |
|
| 39 | - private $manager; |
|
| 40 | - |
|
| 41 | - public function __construct(Manager $manager) { |
|
| 42 | - $this->manager = $manager; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - public function handle(Event $event): void { |
|
| 46 | - if (!($event instanceof PostLoginEvent)) { |
|
| 47 | - return; |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - // prevent setting an empty pw as result of pw-less-login |
|
| 51 | - if ($event->getPassword() === '') { |
|
| 52 | - return; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // If this is already a token login there is nothing to do |
|
| 56 | - if ($event->isTokenLogin()) { |
|
| 57 | - return; |
|
| 58 | - } |
|
| 59 | - |
|
| 60 | - $this->manager->updatePasswords($event->getUser()->getUID(), $event->getPassword()); |
|
| 61 | - } |
|
| 38 | + /** @var Manager */ |
|
| 39 | + private $manager; |
|
| 40 | + |
|
| 41 | + public function __construct(Manager $manager) { |
|
| 42 | + $this->manager = $manager; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + public function handle(Event $event): void { |
|
| 46 | + if (!($event instanceof PostLoginEvent)) { |
|
| 47 | + return; |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + // prevent setting an empty pw as result of pw-less-login |
|
| 51 | + if ($event->getPassword() === '') { |
|
| 52 | + return; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // If this is already a token login there is nothing to do |
|
| 56 | + if ($event->isTokenLogin()) { |
|
| 57 | + return; |
|
| 58 | + } |
|
| 59 | + |
|
| 60 | + $this->manager->updatePasswords($event->getUser()->getUID(), $event->getPassword()); |
|
| 61 | + } |
|
| 62 | 62 | } |