Page MenuHomePhorge

D1546.1775182842.diff
No OneTemporary

Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None

D1546.1775182842.diff

diff --git a/src/app/Console/Commands/DomainAdd.php b/src/app/Console/Commands/DomainAdd.php
new file mode 100644
--- /dev/null
+++ b/src/app/Console/Commands/DomainAdd.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace App\Console\Commands;
+
+use App\Domain;
+use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Queue;
+
+class DomainAdd extends Command
+{
+ /**
+ * The name and signature of the console command.
+ *
+ * @var string
+ */
+ protected $signature = 'domain:add {domain}';
+
+ /**
+ * The console command description.
+ *
+ * @var string
+ */
+ protected $description = "Create a domain.";
+
+ /**
+ * Execute the console command.
+ *
+ * @return mixed
+ */
+ public function handle()
+ {
+ $namespace = \strtolower($this->argument('domain'));
+ $domain = Domain::where('namespace', $namespace)->first();
+
+ if ($domain) {
+ $this->error("Domain already exists.");
+ return 1;
+ }
+
+ Queue::fake(); // ignore LDAP for now
+
+ $domain = Domain::create([
+ 'namespace' => $namespace,
+ 'type' => Domain::TYPE_EXTERNAL,
+ ]);
+
+ $this->info($domain->id);
+ }
+}
diff --git a/src/app/Console/Commands/DomainStatus.php b/src/app/Console/Commands/DomainSetStatus.php
copy from src/app/Console/Commands/DomainStatus.php
copy to src/app/Console/Commands/DomainSetStatus.php
--- a/src/app/Console/Commands/DomainStatus.php
+++ b/src/app/Console/Commands/DomainSetStatus.php
@@ -4,32 +4,23 @@
use App\Domain;
use Illuminate\Console\Command;
+use Illuminate\Support\Facades\Queue;
-class DomainStatus extends Command
+class DomainSetStatus extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
- protected $signature = 'domain:status {domain}';
+ protected $signature = 'domain:set-status {domain} {status}';
/**
* The console command description.
*
* @var string
*/
- protected $description = 'Display the status of a domain';
-
- /**
- * Create a new command instance.
- *
- * @return void
- */
- public function __construct()
- {
- parent::__construct();
- }
+ protected $description = "Set a domain's status.";
/**
* Execute the console command.
@@ -44,7 +35,10 @@
return 1;
}
- $this->info("Found domain: {$domain->id}");
+ Queue::fake(); // ignore LDAP for now
+
+ $domain->status = (int) $this->argument('status');
+ $domain->save();
$this->info($domain->status);
}
diff --git a/src/app/Console/Commands/DomainStatus.php b/src/app/Console/Commands/DomainStatus.php
--- a/src/app/Console/Commands/DomainStatus.php
+++ b/src/app/Console/Commands/DomainStatus.php
@@ -44,8 +44,6 @@
return 1;
}
- $this->info("Found domain: {$domain->id}");
-
$this->info($domain->status);
}
}
diff --git a/src/app/Observers/UserAliasObserver.php b/src/app/Observers/UserAliasObserver.php
--- a/src/app/Observers/UserAliasObserver.php
+++ b/src/app/Observers/UserAliasObserver.php
@@ -21,17 +21,22 @@
{
$alias->alias = \strtolower($alias->alias);
- if ($exists = User::emailExists($alias->alias, true, $alias_exists)) {
+ list($login, $domain) = explode('@', $alias->alias);
+
+ $domain = Domain::where('namespace', $domain)->first();
+
+ if (!$domain) {
+ \Log::error("Failed creating alias {$alias->alias}. Domain does not exist.");
+ return false;
+ }
+/*
+ if ($exists = User::emailExists($alias->alias, true, $alias_exists, !$domain->isPublic())) {
if (!$alias_exists) {
\Log::error("Failed creating alias {$alias->alias}. Email address exists.");
return false;
}
- list($login, $domain) = explode('@', $alias->alias);
-
- $domain = Domain::where('namespace', $domain)->first();
-
- if (!$domain || $domain->isPublic()) {
+ if ($domain->isPublic()) {
\Log::error("Failed creating alias {$alias->alias}. Alias exists in public domain.");
return false;
}
@@ -41,7 +46,7 @@
return false;
}
}
-
+*/
return true;
}
diff --git a/src/tests/Feature/Controller/UsersTest.php b/src/tests/Feature/Controller/UsersTest.php
--- a/src/tests/Feature/Controller/UsersTest.php
+++ b/src/tests/Feature/Controller/UsersTest.php
@@ -418,6 +418,8 @@
{
$jack = $this->getTestUser('jack@kolab.org');
$john = $this->getTestUser('john@kolab.org');
+ $deleted_priv = $this->getTestUser('deleted@kolab.org');
+ $deleted_priv->delete();
// Test empty request
$response = $this->actingAs($john)->post("/api/v4/users", []);
@@ -481,7 +483,7 @@
'last_name' => 'Doe2',
'email' => 'john2.doe2@kolab.org',
'organization' => 'TestOrg',
- 'aliases' => ['useralias1@kolab.org', 'useralias2@kolab.org'],
+ 'aliases' => ['useralias1@kolab.org', 'deleted@kolab.org'],
];
// Missing package
@@ -523,8 +525,8 @@
$this->assertSame('TestOrg', $user->getSetting('organization'));
$aliases = $user->aliases()->orderBy('alias')->get();
$this->assertCount(2, $aliases);
- $this->assertSame('useralias1@kolab.org', $aliases[0]->alias);
- $this->assertSame('useralias2@kolab.org', $aliases[1]->alias);
+ $this->assertSame('deleted@kolab.org', $aliases[0]->alias);
+ $this->assertSame('useralias1@kolab.org', $aliases[1]->alias);
// Assert the new user entitlements
$this->assertUserEntitlements($user, ['groupware', 'mailbox', 'storage', 'storage']);
// Assert the wallet to which the new user should be assigned to

File Metadata

Mime Type
text/plain
Expires
Fri, Apr 3, 2:20 AM (3 h, 11 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822124
Default Alt Text
D1546.1775182842.diff (5 KB)

Event Timeline