mirror of
https://github.com/discourse/discourse.git
synced 2024-12-01 05:13:44 +08:00
Fix: remove hardcoded minimum for username length validation
This commit is contained in:
parent
890346f0b0
commit
725af87980
|
@ -20,6 +20,7 @@ export default DiscourseController.extend(ModalFunctionality, {
|
||||||
canCreateLocal: Discourse.computed.setting('enable_local_logins'),
|
canCreateLocal: Discourse.computed.setting('enable_local_logins'),
|
||||||
showCreateForm: Em.computed.or('hasAuthOptions', 'canCreateLocal'),
|
showCreateForm: Em.computed.or('hasAuthOptions', 'canCreateLocal'),
|
||||||
maxUsernameLength: Discourse.computed.setting('max_username_length'),
|
maxUsernameLength: Discourse.computed.setting('max_username_length'),
|
||||||
|
minUsernameLength: Discourse.computed.setting('min_username_length'),
|
||||||
|
|
||||||
resetForm: function() {
|
resetForm: function() {
|
||||||
|
|
||||||
|
@ -227,7 +228,7 @@ export default DiscourseController.extend(ModalFunctionality, {
|
||||||
}.property('accountUsername'),
|
}.property('accountUsername'),
|
||||||
|
|
||||||
shouldCheckUsernameMatch: function() {
|
shouldCheckUsernameMatch: function() {
|
||||||
return !this.blank('accountUsername') && this.get('accountUsername').length > 2;
|
return !this.blank('accountUsername') && this.get('accountUsername').length >= this.get('minUsernameLength');
|
||||||
},
|
},
|
||||||
|
|
||||||
checkUsernameAvailability: Discourse.debounce(function() {
|
checkUsernameAvailability: Discourse.debounce(function() {
|
||||||
|
|
|
@ -8,12 +8,13 @@ export default ObjectController.extend({
|
||||||
newUsername: null,
|
newUsername: null,
|
||||||
|
|
||||||
maxLength: Discourse.computed.setting('max_username_length'),
|
maxLength: Discourse.computed.setting('max_username_length'),
|
||||||
|
minLength: Discourse.computed.setting('min_username_length'),
|
||||||
newUsernameEmpty: Em.computed.empty('newUsername'),
|
newUsernameEmpty: Em.computed.empty('newUsername'),
|
||||||
saveDisabled: Em.computed.or('saving', 'newUsernameEmpty', 'taken', 'unchanged', 'errorMessage'),
|
saveDisabled: Em.computed.or('saving', 'newUsernameEmpty', 'taken', 'unchanged', 'errorMessage'),
|
||||||
unchanged: Discourse.computed.propertyEqual('newUsername', 'username'),
|
unchanged: Discourse.computed.propertyEqual('newUsername', 'username'),
|
||||||
|
|
||||||
checkTaken: function() {
|
checkTaken: function() {
|
||||||
if( this.get('newUsername') && this.get('newUsername').length < 3 ) {
|
if( this.get('newUsername') && this.get('newUsername').length < this.get('minLength') ) {
|
||||||
this.set('errorMessage', I18n.t('user.name.too_short'));
|
this.set('errorMessage', I18n.t('user.name.too_short'));
|
||||||
} else {
|
} else {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user