Skip to content
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

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

issue 19 #169

wants to merge 7 commits into from

Conversation

sebrittain
Copy link
Contributor

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.

@@ -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
Copy link
Member

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.

Copy link
Contributor Author

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

@Dantemss
Copy link
Member

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:

  • You click the checkbox
  • You set any of the items to green or red.

@sebrittain
Copy link
Contributor Author

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;
}
Copy link
Member

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?

@Dantemss
Copy link
Member

@jpslav should be good to pull

@jpslav
Copy link
Member

jpslav commented Sep 7, 2012

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants