Skip to content

Commit

Permalink
Check that an email was entered on 'forgot password' page.
Browse files Browse the repository at this point in the history
Fixes hotsh#526.

Checks supplied email against basix email regex, and displays flash
error message if no matches are found.
  • Loading branch information
Andrew Stewart committed May 18, 2012
1 parent ca57ed3 commit 5b37ed9
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,13 @@ def forgot_password_new
# with the url to reset their password. Users are then redirected to the
# confirmation page to prevent repost issues
def forgot_password_create
unless params[:email] =~ /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
flash[:error] = "You didn't enter a correct email address. Please check your email and try again."
return render "login/forgot_password"
end

user = User.first(:email => params[:email])

if user.nil?
flash[:error] = "Your account could not be found, please check your email and try again."
render "login/forgot_password"
Expand Down

0 comments on commit 5b37ed9

Please sign in to comment.