diff --git a/frontend/src/api/accounts.js b/frontend/src/api/accounts.js
index fb39ae819..d28af1007 100644
--- a/frontend/src/api/accounts.js
+++ b/frontend/src/api/accounts.js
@@ -6,6 +6,9 @@ export default {
getAll ({ domain, role }) {
return repository.get(`/${resource}/`, { params: { domain, role } })
},
+ get (accountId) {
+ return repository.get(`${resource}/${accountId}/`)
+ },
getRandomPassword () {
return repository.get(`${resource}/random_password`)
},
@@ -14,5 +17,8 @@ export default {
},
create (data) {
return repository.post(`${resource}/`, data)
+ },
+ patch (accountId, data) {
+ return repository.patch(`${resource}/${accountId}/`, data)
}
}
diff --git a/frontend/src/components/identities/AccountCreationForm.vue b/frontend/src/components/identities/AccountCreationForm.vue
index 43df12773..840366c09 100644
--- a/frontend/src/components/identities/AccountCreationForm.vue
+++ b/frontend/src/components/identities/AccountCreationForm.vue
@@ -265,14 +265,14 @@ export default {
try {
await accounts.validate(this.account)
} catch (error) {
+ if (error.response.data.mailbox && error.response.data.mailbox.full_address) {
+ this.$refs[`form_${current}`].$refs.observer.setErrors({
+ username: error.response.data.mailbox.full_address
+ })
+ }
this.$refs[`form_${current}`].$refs.observer.setErrors(error.response.data)
return
}
- if (next === 5 && this.account.random_password) {
- accounts.getRandomPassword().then(resp => {
- this.$set(this.account, 'password', resp.data.password)
- })
- }
this.step = next
},
submit () {
diff --git a/frontend/src/components/identities/AccountForm.vue b/frontend/src/components/identities/AccountForm.vue
new file mode 100644
index 000000000..f54ced640
--- /dev/null
+++ b/frontend/src/components/identities/AccountForm.vue
@@ -0,0 +1,192 @@
+
+
+
+
+
+
+
+ Role
+
+
+
+
+
+
+ {{ $refs.roleForm.roleLabel }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Identification
+
+
+
+
+
+
+ Username: {{ editedAccount.username }}
+
+
+ Enabled
+ mdi-check-circle-outline
+ mdi-close-circle-outline
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Mailbox
+
+
+
+
+
+
+
+ Quota: domain's default value
+
+
+ Quota: {{ account.mailbox.quota }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Cancel
+
+
+ Save
+
+
+
+
+
+
diff --git a/frontend/src/components/identities/AccountGeneralForm.vue b/frontend/src/components/identities/AccountGeneralForm.vue
index 55c23d6bf..d3344ef2d 100644
--- a/frontend/src/components/identities/AccountGeneralForm.vue
+++ b/frontend/src/components/identities/AccountGeneralForm.vue
@@ -7,9 +7,11 @@
>
@@ -26,15 +28,26 @@
outlined
dense
/>
-
+
+
+
+
+ {{ account.password }}
+
+ mdi-clipboard-multiple-outline
+
+
+
+
@@ -49,7 +62,7 @@
diff --git a/frontend/src/components/identities/AccountMailboxForm.vue b/frontend/src/components/identities/AccountMailboxForm.vue
index 5495ce838..437a2ae10 100644
--- a/frontend/src/components/identities/AccountMailboxForm.vue
+++ b/frontend/src/components/identities/AccountMailboxForm.vue
@@ -1,18 +1,5 @@
-
-
-
role.value === this.account.role).label
+ const role = this.accountRoles.find(role => role.value === this.account.role)
+ return role !== undefined ? role.label : ''
},
roleHelp () {
- return this.accountRoles.find(role => role.value === this.account.role).help
+ const role = this.accountRoles.find(role => role.value === this.account.role)
+ return role !== undefined ? role.help : ''
}
},
data () {
diff --git a/frontend/src/components/identities/IdentityList.vue b/frontend/src/components/identities/IdentityList.vue
index 7fd509c1a..03f437a99 100644
--- a/frontend/src/components/identities/IdentityList.vue
+++ b/frontend/src/components/identities/IdentityList.vue
@@ -49,7 +49,7 @@
mdi-dots-horizontal
-
+
@@ -60,11 +60,14 @@
diff --git a/modoboa/admin/api/v1/serializers.py b/modoboa/admin/api/v1/serializers.py
index 33497285f..026cdd771 100644
--- a/modoboa/admin/api/v1/serializers.py
+++ b/modoboa/admin/api/v1/serializers.py
@@ -20,7 +20,7 @@ from modoboa.core import (
)
from modoboa.lib import (
email_utils, exceptions as lib_exceptions, fields as lib_fields,
- permissions, web_utils
+ permissions, validators, web_utils
)
from modoboa.parameters import tools as param_tools
@@ -294,14 +294,20 @@ class WritableAccountSerializer(AccountSerializer):
"master_user": _("Not allowed for this role.")
})
if role == "SimpleUsers":
+ username = data.get("username")
+ if username:
+ try:
+ validators.UTF8EmailValidator()(username)
+ except ValidationError as err:
+ raise ValidationError({"username": err.message})
mailbox = data.get("mailbox")
if mailbox is None:
if not self.instance:
data["mailbox"] = {
- "full_address": data["username"],
+ "full_address": username,
"use_domain_quota": True
}
- elif "full_address" in mailbox and mailbox["full_address"] != data["username"]:
+ elif "full_address" in mailbox and mailbox["full_address"] != username:
raise serializers.ValidationError({
"username": _("Must be equal to mailbox full_address")
})
diff --git a/modoboa/admin/api/v2/serializers.py b/modoboa/admin/api/v2/serializers.py
index ee21bc0ef..0f2dd5e27 100644
--- a/modoboa/admin/api/v2/serializers.py
+++ b/modoboa/admin/api/v2/serializers.py
@@ -146,6 +146,7 @@ class TagSerializer(serializers.Serializer):
class IdentitySerializer(serializers.Serializer):
"""Serializer used for identities."""
+ pk = serializers.IntegerField()
identity = serializers.CharField()
name_or_rcpt = serializers.CharField()
tags = TagSerializer(many=True)