mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 07:53:49 +08:00
FEATURE: don't allow username and password to be the same
This commit is contained in:
@ -22,3 +22,27 @@ test('basicUsernameValidation', function() {
|
||||
equal(controller.get('basicUsernameValidation.ok'), true, 'Prefilled username is valid');
|
||||
equal(controller.get('basicUsernameValidation.reason'), I18n.t('user.username.prefilled'), 'Prefilled username is valid');
|
||||
});
|
||||
|
||||
test('passwordValidation', function() {
|
||||
var subject = this.subject;
|
||||
|
||||
var controller = subject();
|
||||
controller.set('passwordRequired', true);
|
||||
controller.set('accountUsername', 'porkchops');
|
||||
controller.set('prefilledUsername', 'porkchops');
|
||||
|
||||
controller.set('accountPassword', 'b4fcdae11f9167');
|
||||
equal(controller.get('passwordValidation.ok'), true, 'Password is ok');
|
||||
equal(controller.get('passwordValidation.reason'), I18n.t('user.password.ok'), 'Password is valid');
|
||||
|
||||
var testInvalidPassword = function(password, expectedReason) {
|
||||
var controller = subject();
|
||||
controller.set('accountPassword', password);
|
||||
equal(controller.get('passwordValidation.failed'), true, 'password should be invalid: ' + password);
|
||||
equal(controller.get('passwordValidation.reason'), expectedReason, 'password validation reason: ' + password + ', ' + expectedReason);
|
||||
};
|
||||
|
||||
testInvalidPassword('', undefined);
|
||||
testInvalidPassword('x', I18n.t('user.password.too_short'));
|
||||
testInvalidPassword('porkchops', I18n.t('user.password.same_as_username'));
|
||||
});
|
||||
|
Reference in New Issue
Block a user