-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
issue 19 #169
base: master
Are you sure you want to change the base?
issue 19 #169
Conversation
@@ -37,7 +37,7 @@ class User < ActiveRecord::Base | |||
|
|||
validates_presence_of :first_name, :last_name, :username, :user_profile | |||
validates_uniqueness_of :username, :case_sensitive => false | |||
validates_length_of :username, :in => 3..40 | |||
validates_length_of :username, :in => 8..40 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want to enforce this. Short usernames are probably fine.
Just enforce that the password has at least 8 characters.
You could write a custom validation to ensure that the password also has at least 1 letter and 1 number, but that's probably not necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops thought that variable was :password, not :username, fixed now
This still has a few problems, specifically: If you click the checkbox before typing the password, the button won't be enabled. The password confirmation affects the requirement box. Probably just want to add another item that says something like "Password confirmation matches" and set it to green if confirmation == password Make the agreement_checkbox click code into a javascript function you can call. This function needs to work both ways, i.e. enable the button if everything is ok, disable it if anything is not ok (just add an else statement). Call this function when:
|
Sorry I thought this was all working when I committed it a few days ago, I fixed the problem and I think it's all good now. |
} else { | ||
$('#number').removeClass('valid').addClass('invalid'); | ||
number = false; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice. Can you add one more check that is valid if the password and the confirmation match?
@jpslav should be good to pull |
thanks @sebrittain for this. for now, I'm going to hold off on merging it in until we can make sure that we have these JS validations also represented in the model class, and at that point we may consider using a gem as in http://railscasts.com/episodes/263-client-side-validations to generate model-agreeing validations for us. |
Requires a user to create a password with 8 characters including one letter and one number. It also adds a check-box that shows the user which requirements they have met.