mirror of
https://github.com/jwinterm/modoboa.git
synced 2026-10-17 05:41:25 +02:00
Make sure email and username are the same even for super admins.
see #1240
This commit is contained in:
@@ -147,13 +147,14 @@ class AccountFormGeneral(forms.ModelForm):
|
||||
|
||||
def clean_username(self):
|
||||
"""username must be a valid email address for simple users."""
|
||||
username = self.cleaned_data["username"]
|
||||
if "role" not in self.cleaned_data:
|
||||
return self.cleaned_data["username"]
|
||||
if self.cleaned_data["role"] != "SimpleUsers":
|
||||
return self.cleaned_data["username"]
|
||||
uname = self.cleaned_data["username"].lower()
|
||||
validate_utf8_email(uname)
|
||||
return uname
|
||||
return username
|
||||
if self.cleaned_data["role"] != "SimpleUsers" and "@" not in username:
|
||||
return username
|
||||
username = username.lower()
|
||||
validate_utf8_email(username)
|
||||
return username
|
||||
|
||||
def clean(self):
|
||||
"""Check master user mode."""
|
||||
|
||||
@@ -560,18 +560,25 @@ Identities.prototype = {
|
||||
*/
|
||||
emailChanged: function(event) {
|
||||
var $target = get_target(event);
|
||||
var $username = $('#id_username');
|
||||
|
||||
if ($target.val() !== this.originalEmail) {
|
||||
$('#id_create_alias_with_old_address').parents(".form-group").show();
|
||||
}
|
||||
if ($username.val() !== $target.val()) {
|
||||
$username.val($target.val());
|
||||
}
|
||||
},
|
||||
|
||||
generalform_init: function(notrigger) {
|
||||
$("#id_role").change($.proxy(function(e) {
|
||||
var $role = $('#id_role');
|
||||
|
||||
$role.change($.proxy(function(e) {
|
||||
var $this = $(e.target);
|
||||
var value = $this.val();
|
||||
var email = $('#id_email').val();
|
||||
|
||||
if (value == "SimpleUsers" || value === "") {
|
||||
if (value === 'SimpleUsers' || email !== '') {
|
||||
this.simpleuser_mode();
|
||||
} else {
|
||||
this.normal_mode(value);
|
||||
@@ -581,12 +588,12 @@ Identities.prototype = {
|
||||
var $this = $(e.target);
|
||||
this.togglePasswordInputs(!$this.prop('checked'));
|
||||
}, this));
|
||||
this.toggle_master_user($("#id_role").val());
|
||||
this.toggle_master_user($role.val());
|
||||
$('#id_create_alias_with_old_address').parents('.form-group').hide();
|
||||
if (notrigger !== undefined && notrigger) {
|
||||
return;
|
||||
}
|
||||
$("#id_role").trigger("change");
|
||||
$role.trigger("change");
|
||||
},
|
||||
|
||||
mailform_init: function() {
|
||||
@@ -657,7 +664,7 @@ Identities.prototype = {
|
||||
$("#wizard").cwizard({
|
||||
formid: "newaccount_form",
|
||||
transition_callbacks: {
|
||||
"mail": this.mailform_prefill
|
||||
mail: this.mailform_prefill
|
||||
},
|
||||
success_callback: $.proxy(this.reload_listing, this)
|
||||
});
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by Django 1.11.11 on 2018-07-13 08:14
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('core', '0015_auto_20180112_1642'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='user',
|
||||
name='language',
|
||||
field=models.CharField(choices=[('cs', '\u010de\u0161tina'), ('de', 'deutsch'), ('en', 'english'), ('el_GR', '\u03b5\u03bb\u03bb\u03b7\u03bd\u03b9\u03ba\u03ac'), ('es', 'espa\xf1ol'), ('fr', 'fran\xe7ais'), ('it', 'italiano'), ('ja_JP', '\u65e5\u672c\u306e'), ('nl', 'nederlands'), ('pt_PT', 'portugu\xeas'), ('pt_BR', 'portugu\xeas (BR)'), ('pl_PL', 'polski'), ('ro_RO', 'Rom\xe2n\u0103'), ('ru', '\u0440\u0443\u0441\u0441\u043a\u0438\u0439'), ('sv', 'svenska'), ('zh_TW', '\u4e2d\u6587\uff08\u53f0\u7063\uff09')], default='en', help_text='Prefered language to display pages.', max_length=10, verbose_name='language'),
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user