traccar / traccar-web

Traccar GPS Tracking System
https://www.traccar.org
Apache License 2.0
810 stars 1.12k forks source link

Issues creating new users from manager account with own email change restriction #1261

Closed troianvasile closed 1 month ago

troianvasile commented 1 month ago

Describe the bug I have encountered this issues upon creating a manager account and setting limits (example 5 devices and 5 users ). If the checkbox to restrict the manager to change his email address is set on the manager. The manager cannot create sub users due to the email field being disabled in the new user screen. This might be due to the fact the email field is disabled on the Account section so the manager cannot change his own email.

To Reproduce Steps to reproduce the behavior:

  1. Go to Admin account and create a manager account with the ability to create users
  2. Check the box so the Manger cannot change his own email address under permissions.
  3. Login as the manager and go to the users section and try to add a new user
  4. The manager cannot add a new user as the email field is disabled.

Expected behavior Manager with ability to create users to be able to create the users.

Additional context I have seen the issue on Traccar 6.2 initially but i have now installed a fresh copy of Traccar 6.3 and checked for the issue and it is still present.

troianvasile commented 1 month ago

I sorted the issue locally on my setup by adding an extra condition in UserPage.jsx line 144 Changing the email field from :

 <TextField
                value={item.email || ''}
                onChange={(e) => setItem({ ...item, email: e.target.value })}
                label={t('userEmail')}
                disabled={fixedEmail}
              />

to :

 <TextField
                value={item.email || ''}
                onChange={(e) => setItem({ ...item, email: e.target.value })}
                label={t('userEmail')}
                disabled={fixedEmail&& **(item.id === currentUser.id)**}
              />