mirror of
https://github.com/codeninjasllc/discourse.git
synced 2024-11-24 08:09:13 -05:00
Username change: check length in js, we don't need the server to do it
This commit is contained in:
parent
b6224b014c
commit
c24f6d3d51
1 changed files with 16 additions and 12 deletions
|
@ -26,18 +26,22 @@ Discourse.PreferencesUsernameController = Discourse.ObjectController.extend({
|
|||
}).property('newUsername', 'content.username'),
|
||||
|
||||
checkTaken: (function() {
|
||||
var _this = this;
|
||||
this.set('taken', false);
|
||||
this.set('errorMessage', null);
|
||||
if (this.blank('newUsername')) return;
|
||||
if (this.get('unchanged')) return;
|
||||
Discourse.User.checkUsername(this.get('newUsername')).then(function(result) {
|
||||
if (result.errors) {
|
||||
return _this.set('errorMessage', result.errors.join(' '));
|
||||
} else if (result.available === false) {
|
||||
return _this.set('taken', true);
|
||||
}
|
||||
});
|
||||
if( this.get('newUsername') && this.get('newUsername').length < 3 ) {
|
||||
this.set('errorMessage', Em.String.i18n('user.name.too_short'));
|
||||
} else {
|
||||
var _this = this;
|
||||
this.set('taken', false);
|
||||
this.set('errorMessage', null);
|
||||
if (this.blank('newUsername')) return;
|
||||
if (this.get('unchanged')) return;
|
||||
Discourse.User.checkUsername(this.get('newUsername')).then(function(result) {
|
||||
if (result.errors) {
|
||||
return _this.set('errorMessage', result.errors.join(' '));
|
||||
} else if (result.available === false) {
|
||||
return _this.set('taken', true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}).observes('newUsername'),
|
||||
|
||||
saveButtonText: (function() {
|
||||
|
|
Loading…
Reference in a new issue