mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-15 11:42:15 +01:00
Added timezone to registration
This commit is contained in:
@@ -6,6 +6,7 @@ namespace App\Actions\Fortify;
|
||||
|
||||
use App\Models\Organization;
|
||||
use App\Models\User;
|
||||
use App\Service\TimezoneService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
@@ -48,11 +49,17 @@ class CreateNewUser implements CreatesNewUsers
|
||||
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature() ? ['accepted', 'required'] : '',
|
||||
])->validate();
|
||||
|
||||
return DB::transaction(function () use ($input) {
|
||||
$timezone = 'UTC';
|
||||
if (array_key_exists('timezone', $input) && is_string($input['timezone']) && app(TimezoneService::class)->isValid($input['timezone'])) {
|
||||
$timezone = $input['timezone'];
|
||||
}
|
||||
|
||||
return DB::transaction(function () use ($input, $timezone) {
|
||||
return tap(User::create([
|
||||
'name' => $input['name'],
|
||||
'email' => $input['email'],
|
||||
'password' => Hash::make($input['password']),
|
||||
'timezone' => $timezone,
|
||||
]), function (User $user) {
|
||||
$this->createTeam($user);
|
||||
});
|
||||
|
||||
@@ -53,6 +53,7 @@ class ClockifyTimeEntriesImporter extends DefaultImporter
|
||||
'email' => $record['Email'],
|
||||
], [
|
||||
'name' => $record['User'],
|
||||
'timezone' => 'UTC',
|
||||
'is_placeholder' => true,
|
||||
]);
|
||||
$clientId = null;
|
||||
|
||||
@@ -12,6 +12,7 @@ use App\Models\Task;
|
||||
use App\Models\User;
|
||||
use App\Service\ColorService;
|
||||
use App\Service\Import\ImportDatabaseHelper;
|
||||
use App\Service\TimezoneService;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
|
||||
abstract class DefaultImporter implements ImporterContract
|
||||
@@ -47,6 +48,8 @@ abstract class DefaultImporter implements ImporterContract
|
||||
|
||||
protected ColorService $colorService;
|
||||
|
||||
protected TimezoneService $timezoneService;
|
||||
|
||||
public function init(Organization $organization): void
|
||||
{
|
||||
$this->organization = $organization;
|
||||
@@ -62,6 +65,10 @@ abstract class DefaultImporter implements ImporterContract
|
||||
'required',
|
||||
'max:255',
|
||||
],
|
||||
'timezone' => [
|
||||
'required',
|
||||
'timezone:all',
|
||||
],
|
||||
]);
|
||||
$this->projectImportHelper = new ImportDatabaseHelper(Project::class, ['name', 'organization_id'], true, function (Builder $builder) {
|
||||
return $builder->where('organization_id', $this->organization->id);
|
||||
@@ -97,6 +104,7 @@ abstract class DefaultImporter implements ImporterContract
|
||||
]);
|
||||
$this->timeEntriesCreated = 0;
|
||||
$this->colorService = app(ColorService::class);
|
||||
$this->timezoneService = app(TimezoneService::class);
|
||||
}
|
||||
|
||||
#[\Override]
|
||||
|
||||
@@ -83,6 +83,7 @@ class TogglDataImporter extends DefaultImporter
|
||||
'email' => $workspaceUser->email,
|
||||
], [
|
||||
'name' => $workspaceUser->name,
|
||||
'timezone' => $workspaceUser->timezone ?? 'UTC',
|
||||
'is_placeholder' => true,
|
||||
], (string) $workspaceUser->id);
|
||||
}
|
||||
|
||||
@@ -53,6 +53,7 @@ class TogglTimeEntriesImporter extends DefaultImporter
|
||||
'email' => $record['Email'],
|
||||
], [
|
||||
'name' => $record['User'],
|
||||
'timezone' => 'UTC',
|
||||
'is_placeholder' => true,
|
||||
]);
|
||||
$clientId = null;
|
||||
|
||||
@@ -32,4 +32,9 @@ class TimezoneService
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
public function isValid(string $timezone): bool
|
||||
{
|
||||
return in_array($timezone, $this->getTimezones(), true);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user