mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-10-10 14:53:17 +01:00
Allow only one running time entry per user across organizations
The running time entry check in the store endpoint was scoped to the member, so a user could start a time entry in each of their organizations. The active time entry endpoint and the database consistency check expect only one running time entry per user.
This commit is contained in:
@@ -630,7 +630,8 @@ class TimeEntryController extends Controller
|
||||
*/
|
||||
private function storeTimeEntry(Organization $organization, Member $member, TimeEntryStoreRequest $request): JsonResource
|
||||
{
|
||||
if ($request->input('end') === null && TimeEntry::query()->whereBelongsTo($member, 'member')->where('end', null)->exists()) {
|
||||
// A user can only have one running time entry, across all organizations
|
||||
if ($request->input('end') === null && TimeEntry::query()->where('user_id', $member->user_id)->whereNull('end')->exists()) {
|
||||
throw new TimeEntryStillRunningApiException;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user