Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117384327
D4223.1774822618.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None
D4223.1774822618.diff
View Options
diff --git a/src/app/Domain.php b/src/app/Domain.php
--- a/src/app/Domain.php
+++ b/src/app/Domain.php
@@ -191,24 +191,20 @@
return;
}
+ // if we have confirmed ownership of or management access to the domain, then we have
+ // also confirmed the domain exists in DNS.
if ($new_status & self::STATUS_CONFIRMED) {
- // if we have confirmed ownership of or management access to the domain, then we have
- // also confirmed the domain exists in DNS.
- $new_status |= self::STATUS_VERIFIED;
- $new_status |= self::STATUS_ACTIVE;
+ $new_status |= self::STATUS_VERIFIED | self::STATUS_ACTIVE;
}
- if ($new_status & self::STATUS_DELETED && $new_status & self::STATUS_ACTIVE) {
- $new_status ^= self::STATUS_ACTIVE;
- }
-
- if ($new_status & self::STATUS_SUSPENDED && $new_status & self::STATUS_ACTIVE) {
- $new_status ^= self::STATUS_ACTIVE;
+ // it can't be deleted-or-suspended and active
+ if ($new_status & self::STATUS_DELETED || $new_status & self::STATUS_SUSPENDED) {
+ $new_status &= ~self::STATUS_ACTIVE;
}
// if the domain is now active, it is not new anymore.
- if ($new_status & self::STATUS_ACTIVE && $new_status & self::STATUS_NEW) {
- $new_status ^= self::STATUS_NEW;
+ if ($new_status & self::STATUS_ACTIVE) {
+ $new_status &= ~self::STATUS_NEW;
}
$this->attributes['status'] = $new_status;
diff --git a/src/app/Http/Controllers/RelationController.php b/src/app/Http/Controllers/RelationController.php
--- a/src/app/Http/Controllers/RelationController.php
+++ b/src/app/Http/Controllers/RelationController.php
@@ -108,7 +108,8 @@
$with_ldap = \config('app.with_ldap');
- $state['isReady'] = (!isset($state['isImapReady']) || $state['isImapReady'])
+ $state['isReady'] = (!isset($state['isActive']) || $state['isActive'])
+ && (!isset($state['isImapReady']) || $state['isImapReady'])
&& (!$with_ldap || !isset($state['isLdapReady']) || $state['isLdapReady'])
&& (!isset($state['isVerified']) || $state['isVerified'])
&& (!isset($state['isConfirmed']) || $state['isConfirmed']);
diff --git a/src/app/Observers/DomainObserver.php b/src/app/Observers/DomainObserver.php
--- a/src/app/Observers/DomainObserver.php
+++ b/src/app/Observers/DomainObserver.php
@@ -90,17 +90,16 @@
public function restoring(Domain $domain)
{
// Make sure it's not DELETED/LDAP_READY/SUSPENDED
- if ($domain->isDeleted()) {
- $domain->status ^= Domain::STATUS_DELETED;
- }
- if ($domain->isLdapReady()) {
- $domain->status ^= Domain::STATUS_LDAP_READY;
- }
- if ($domain->isSuspended()) {
- $domain->status ^= Domain::STATUS_SUSPENDED;
- }
+ $domain->status &= ~Domain::STATUS_DELETED;
+ $domain->status &= ~Domain::STATUS_LDAP_READY;
+ $domain->status &= ~Domain::STATUS_SUSPENDED;
+
+ // TODO: Imho VERIFIED/CONFIRMED status should be unset too
+
if ($domain->isConfirmed() && $domain->isVerified()) {
$domain->status |= Domain::STATUS_ACTIVE;
+ } else {
+ $domain->status |= Domain::STATUS_NEW;
}
// Note: $domain->save() is invoked between 'restoring' and 'restored' events
diff --git a/src/app/Observers/GroupObserver.php b/src/app/Observers/GroupObserver.php
--- a/src/app/Observers/GroupObserver.php
+++ b/src/app/Observers/GroupObserver.php
@@ -72,18 +72,8 @@
*/
public function restoring(Group $group)
{
- // Make sure it's not DELETED/LDAP_READY/SUSPENDED anymore
- if ($group->isDeleted()) {
- $group->status ^= Group::STATUS_DELETED;
- }
- if ($group->isLdapReady()) {
- $group->status ^= Group::STATUS_LDAP_READY;
- }
- if ($group->isSuspended()) {
- $group->status ^= Group::STATUS_SUSPENDED;
- }
-
- $group->status |= Group::STATUS_ACTIVE;
+ // Reset the status
+ $group->status = Group::STATUS_NEW;
// Note: $group->save() is invoked between 'restoring' and 'restored' events
}
diff --git a/src/app/Observers/UserObserver.php b/src/app/Observers/UserObserver.php
--- a/src/app/Observers/UserObserver.php
+++ b/src/app/Observers/UserObserver.php
@@ -140,21 +140,8 @@
*/
public function restoring(User $user)
{
- // Make sure it's not DELETED/LDAP_READY/IMAP_READY/SUSPENDED anymore
- if ($user->isDeleted()) {
- $user->status ^= User::STATUS_DELETED;
- }
- if ($user->isLdapReady()) {
- $user->status ^= User::STATUS_LDAP_READY;
- }
- if ($user->isImapReady()) {
- $user->status ^= User::STATUS_IMAP_READY;
- }
- if ($user->isSuspended()) {
- $user->status ^= User::STATUS_SUSPENDED;
- }
-
- $user->status |= User::STATUS_ACTIVE;
+ // Reset the status
+ $user->status = User::STATUS_NEW;
// Note: $user->save() is invoked between 'restoring' and 'restored' events
}
diff --git a/src/tests/Feature/GroupTest.php b/src/tests/Feature/GroupTest.php
--- a/src/tests/Feature/GroupTest.php
+++ b/src/tests/Feature/GroupTest.php
@@ -163,11 +163,16 @@
Queue::fake();
$user = $this->getTestUser('user-test@kolabnow.com');
- $group = $this->getTestGroup('group-test@kolabnow.com');
+ $group = $this->getTestGroup('group-test@kolabnow.com', [
+ 'status' => Group::STATUS_ACTIVE | Group::STATUS_LDAP_READY | Group::STATUS_SUSPENDED,
+ ]);
$group->assignToWallet($user->wallets->first());
$entitlements = \App\Entitlement::where('entitleable_id', $group->id);
+ $this->assertTrue($group->isSuspended());
+ $this->assertTrue($group->isLdapReady());
+ $this->assertTrue($group->isActive());
$this->assertSame(1, $entitlements->count());
$group->delete();
@@ -185,7 +190,7 @@
$this->assertFalse($group->isDeleted());
$this->assertFalse($group->isSuspended());
$this->assertFalse($group->isLdapReady());
- $this->assertTrue($group->isActive());
+ $this->assertFalse($group->isActive());
$this->assertSame(1, $entitlements->count());
$entitlements->get()->each(function ($ent) {
diff --git a/src/tests/Feature/UserTest.php b/src/tests/Feature/UserTest.php
--- a/src/tests/Feature/UserTest.php
+++ b/src/tests/Feature/UserTest.php
@@ -1121,7 +1121,7 @@
$this->assertFalse($userA->isSuspended());
$this->assertFalse($userA->isLdapReady());
$this->assertFalse($userA->isImapReady());
- $this->assertTrue($userA->isActive());
+ $this->assertFalse($userA->isActive());
$this->assertTrue($userB->fresh()->trashed());
$this->assertTrue($domainB->fresh()->trashed());
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Mar 29, 10:16 PM (4 d, 5 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18777489
Default Alt Text
D4223.1774822618.diff (6 KB)
Attached To
Mode
D4223: Display users with no ACTIVE flag as Not Ready, code cleanup
Attached
Detach File
Event Timeline