mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-18 05:51:26 +02:00
do not override variable.
This commit is contained in:
@@ -340,14 +340,15 @@ class User(PermissionsMixin):
|
||||
if len(row) < 7:
|
||||
raise BadRequest(_("Invalid line"))
|
||||
|
||||
role = row[6].strip()
|
||||
desired_role = row[6].strip()
|
||||
if not user.is_superuser:
|
||||
allowed_roles = get_account_roles(user)
|
||||
allowed_roles = [role[0] for role in allowed_roles]
|
||||
if role not in allowed_roles:
|
||||
raise PermDeniedException(
|
||||
_("You can't import an account with a role greater than yours")
|
||||
)
|
||||
if desired_role not in allowed_roles:
|
||||
raise PermDeniedException(_(
|
||||
"You can't import an account with a role greater than "
|
||||
"yours"
|
||||
))
|
||||
|
||||
self.username = row[1].strip()
|
||||
try:
|
||||
@@ -357,7 +358,7 @@ class User(PermissionsMixin):
|
||||
else:
|
||||
raise Conflict
|
||||
|
||||
if role == "SimpleUsers":
|
||||
if desired_role == "SimpleUsers":
|
||||
if len(row) < 8 or not row[7].strip():
|
||||
raise BadRequest(
|
||||
_("The simple user '%s' must have a valid email address"
|
||||
@@ -377,7 +378,7 @@ class User(PermissionsMixin):
|
||||
self.last_name = row[4].strip()
|
||||
self.is_active = (row[5].strip() in ["True", "1", "yes", "y"])
|
||||
self.save(creator=user)
|
||||
self.set_role(role)
|
||||
self.set_role(desired_role)
|
||||
if len(row) < 8:
|
||||
return
|
||||
events.raiseEvent("AccountImported", user, self, row[7:])
|
||||
|
||||
Reference in New Issue
Block a user