Skip to content

Commit

Permalink
Merge pull request #104 from fleetbase/dev-v1.5.1
Browse files Browse the repository at this point in the history
v1.5.1
  • Loading branch information
roncodes authored Jul 30, 2024
2 parents c8aac98 + 0424f4b commit f6a1345
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fleetbase/core-api",
"version": "1.5.0",
"version": "1.5.1",
"description": "Core Framework and Resources for Fleetbase API",
"keywords": [
"fleetbase",
Expand Down
4 changes: 3 additions & 1 deletion migrations/2023_04_25_094301_create_users_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('users');
Schema::withoutForeignKeyConstraints(function () {
Schema::dropIfExists('users');
});
}
};
4 changes: 3 additions & 1 deletion migrations/2023_04_25_094305_create_companies_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('companies');
Schema::withoutForeignKeyConstraints(function () {
Schema::dropIfExists('companies');
});
}
};
4 changes: 3 additions & 1 deletion migrations/2023_04_25_094308_create_files_table.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ public function up()
*/
public function down()
{
Schema::dropIfExists('files');
Schema::withoutForeignKeyConstraints(function () {
Schema::dropIfExists('files');
});
}
};
2 changes: 1 addition & 1 deletion src/Http/Controllers/Internal/v1/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public function login(LoginRequest $request)
return response()->error('Authentication failed using password provided.', 401, ['code' => 'invalid_password']);
}

if ($user->isNotVerified()) {
if ($user->isNotVerified() && $user->isNotAdmin()) {
return response()->error('User is not verified.', 400, ['code' => 'not_verified']);
}

Expand Down
10 changes: 4 additions & 6 deletions src/Http/Controllers/Internal/v1/OnboardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,10 @@ public function createAccount(OnboardRequest $request)
// assign user to organization
$user->assignCompany($company);

// create company user
CompanyUser::create([
'user_uuid' => $user->uuid,
'company_uuid' => $company->uuid,
'status' => 'active',
]);
// Create company user record
if (CompanyUser::where(['company_uuid' => $company->uuid, 'user_uuid' => $user->uuid])->doesntExist()) {
CompanyUser::create(['company_uuid' => $company->uuid, 'user_uuid' => $user->uuid, 'status' => $user->status]);
}

// send account created event
event(new AccountCreated($user, $company));
Expand Down
2 changes: 1 addition & 1 deletion src/Http/Requests/OnboardRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function authorize()
public function rules()
{
return [
'name' => ['required', 'min:2', 'regex:/^[a-zA-ZÀ-ÿ\'\- ]+$/u', new ExcludeWords($this->excludedWords)],
'name' => ['required', 'min:2', 'regex:/^[a-zA-ZÀ-ÿ\'\-\. ]+$/u', new ExcludeWords($this->excludedWords)],
'email' => ['required', 'email', Rule::unique('users', 'email')->whereNull('deleted_at'), new EmailDomainExcluded()],
'phone' => ['required', new ValidPhoneNumber(), Rule::unique('users', 'phone')->whereNull('deleted_at')],
'password' => ['required', 'confirmed', 'min:4', 'max:24'],
Expand Down
2 changes: 1 addition & 1 deletion src/Listeners/HandleAccountCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function handle(AccountCreated $event)
// Send user a verification email
$user = $event->user;

if ($user) {
if ($user && $user->isNotAdmin()) {
// Create and send verification code
try {
VerificationCode::generateEmailVerificationFor($user);
Expand Down

0 comments on commit f6a1345

Please sign in to comment.