Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F117793025
D1666.1775259720.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
5 KB
Referenced Files
None
Subscribers
None
D1666.1775259720.diff
View Options
diff --git a/src/app/Http/Controllers/API/V4/UsersController.php b/src/app/Http/Controllers/API/V4/UsersController.php
--- a/src/app/Http/Controllers/API/V4/UsersController.php
+++ b/src/app/Http/Controllers/API/V4/UsersController.php
@@ -629,14 +629,14 @@
return \trans('validation.entryinvalid', ['attribute' => $attribute]);
}
- list($login, $domain) = explode('@', $email);
+ list($login, $domain) = explode('@', Str::lower($email));
if (strlen($login) === 0 || strlen($domain) === 0) {
return \trans('validation.entryinvalid', ['attribute' => $attribute]);
}
// Check if domain exists
- $domain = Domain::where('namespace', Str::lower($domain))->first();
+ $domain = Domain::where('namespace', $domain)->first();
if (empty($domain)) {
return \trans('validation.domaininvalid');
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
@@ -24,6 +24,8 @@
}
}
+ $domain->namespace = \strtolower($domain->namespace);
+
$domain->status |= Domain::STATUS_NEW | Domain::STATUS_ACTIVE;
}
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
@@ -30,6 +30,8 @@
}
}
+ $user->email = \strtolower($user->email);
+
// only users that are not imported get the benefit of the doubt.
$user->status |= User::STATUS_NEW | User::STATUS_ACTIVE;
diff --git a/src/database/seeds/local/UserSeeder.php b/src/database/seeds/local/UserSeeder.php
--- a/src/database/seeds/local/UserSeeder.php
+++ b/src/database/seeds/local/UserSeeder.php
@@ -133,11 +133,8 @@
[
'email' => 'jeroen@jeroen.jeroen',
'password' => 'jeroen',
+ 'role' => 'admin',
]
);
-
- $jeroen->role = "admin";
-
- $jeroen->save();
}
}
diff --git a/src/tests/Feature/DomainTest.php b/src/tests/Feature/DomainTest.php
--- a/src/tests/Feature/DomainTest.php
+++ b/src/tests/Feature/DomainTest.php
@@ -47,6 +47,27 @@
parent::tearDown();
}
+ /**
+ * Test domain create/creating observer
+ */
+ public function testCreate(): void
+ {
+ Queue::fake();
+
+ $domain = Domain::create([
+ 'namespace' => 'GMAIL.COM',
+ 'status' => Domain::STATUS_NEW,
+ 'type' => Domain::TYPE_EXTERNAL,
+ ]);
+
+ $result = Domain::where('namespace', 'gmail.com')->first();
+
+ $this->assertSame('gmail.com', $result->namespace);
+ $this->assertSame($domain->id, $result->id);
+ $this->assertSame($domain->type, $result->type);
+ $this->assertSame(Domain::STATUS_NEW | Domain::STATUS_ACTIVE, $result->status);
+ }
+
/**
* Test domain creating jobs
*/
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
@@ -55,10 +55,64 @@
$this->markTestIncomplete();
}
+ /**
+ * Verify a wallet assigned a controller is among the accounts of the assignee.
+ */
+ public function testAccounts(): void
+ {
+ $userA = $this->getTestUser('UserAccountA@UserAccount.com');
+ $userB = $this->getTestUser('UserAccountB@UserAccount.com');
+
+ $this->assertTrue($userA->wallets()->count() == 1);
+
+ $userA->wallets()->each(
+ function ($wallet) use ($userB) {
+ $wallet->addController($userB);
+ }
+ );
+
+ $this->assertTrue($userB->accounts()->get()[0]->id === $userA->wallets()->get()[0]->id);
+ }
+
+ public function testCanDelete(): void
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testCanRead(): void
+ {
+ $this->markTestIncomplete();
+ }
+
+ public function testCanUpdate(): void
+ {
+ $this->markTestIncomplete();
+ }
+
+ /**
+ * Test user create/creating observer
+ */
+ public function testCreate(): void
+ {
+ Queue::fake();
+
+ $domain = \config('app.domain');
+
+ $user = User::create([
+ 'email' => 'USER-test@' . \strtoupper($domain)
+ ]);
+
+ $result = User::where('email', 'user-test@' . $domain)->first();
+
+ $this->assertSame('user-test@' . $domain, $result->email);
+ $this->assertSame($user->id, $result->id);
+ $this->assertSame(User::STATUS_NEW | User::STATUS_ACTIVE, $result->status);
+ }
+
/**
* Verify user creation process
*/
- public function testUserCreateJob(): void
+ public function testCreateJobs(): void
{
// Fake the queue, assert that no jobs were pushed...
Queue::fake();
@@ -95,45 +149,6 @@
*/
}
- /**
- * Verify a wallet assigned a controller is among the accounts of the assignee.
- */
- public function testListUserAccounts(): void
- {
- $userA = $this->getTestUser('UserAccountA@UserAccount.com');
- $userB = $this->getTestUser('UserAccountB@UserAccount.com');
-
- $this->assertTrue($userA->wallets()->count() == 1);
-
- $userA->wallets()->each(
- function ($wallet) use ($userB) {
- $wallet->addController($userB);
- }
- );
-
- $this->assertTrue($userB->accounts()->get()[0]->id === $userA->wallets()->get()[0]->id);
- }
-
- public function testAccounts(): void
- {
- $this->markTestIncomplete();
- }
-
- public function testCanDelete(): void
- {
- $this->markTestIncomplete();
- }
-
- public function testCanRead(): void
- {
- $this->markTestIncomplete();
- }
-
- public function testCanUpdate(): void
- {
- $this->markTestIncomplete();
- }
-
/**
* Tests for User::domains()
*/
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Apr 3, 11:42 PM (14 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18820915
Default Alt Text
D1666.1775259720.diff (5 KB)
Attached To
Mode
D1666: Make sure user email and domain is lowercase
Attached
Detach File
Event Timeline