finished write-up for broken auth

This commit is contained in:
cktricky
2013-11-14 10:47:27 -05:00
parent 5fff355181
commit b84c8d4cc7
3 changed files with 21 additions and 7 deletions
+1 -1
View File
@@ -16,7 +16,7 @@ class UsersController < ApplicationController
else else
@user = user @user = user
flash[:error] = user.errors.full_messages.to_sentence flash[:error] = user.errors.full_messages.to_sentence
redirect_to :sign_up redirect_to :signup
end end
end end
+7 -1
View File
@@ -5,7 +5,13 @@ class User < ActiveRecord::Base
:length => {:within => 6..40}, :length => {:within => 6..40},
:on => :create, :on => :create,
:if => :password#, :if => :password#,
#:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/} =begin :format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
validates :password, :presence => true,
:confirmation => true,
:on => :update,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
=end
validates_presence_of :email validates_presence_of :email
validates_uniqueness_of :email validates_uniqueness_of :email
validates_format_of :email, :with => /.+@.+\..+/i validates_format_of :email, :with => /.+@.+\..+/i
@@ -70,11 +70,19 @@
<li>1 special character</li> <li>1 special character</li>
</p> </p>
<pre class="ruby"> <pre class="ruby">
validates :password, :presence => true, # VALIDATE PASSWORD BOTH AT CREATION AND WHEN UPDATING
:confirmation => true, validates :password, :presence => true,
:length => {:within => 6..40}, :confirmation => true,
:on => :create, :length => {:within => 6..40},
<span style="background-color: yellow">:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}</span> :on => :create,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
validates :password, :presence => true,
:confirmation => true,
:on => :update,
:if => :password,
:format => {:with => /\A.*(?=.{10,})(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[\@\#\$\%\^\&\+\=]).*\z/}
</pre> </pre>
</div> </div>
</div> </div>