else
user = User.find_by_display_name(params[:display_name])
- redirect_to root_path if !user || user.active?
+ redirect_to root_path if user.nil? || user.active?
end
end
def confirm_resend
- if user = User.find_by_display_name(params[:display_name])
- Notifier.signup_confirm(user, user.tokens.create).deliver_now
- flash[:notice] = t "user.confirm_resend.success", :email => "your email" # user.email
- else
+ user = User.find_by_display_name(params[:display_name])
+ token = UserToken.find_by_token(session[:token])
+
+ if user.nil? || token.nil? || token.user != user
flash[:error] = t "user.confirm_resend.failure", :name => params[:display_name]
+ else
+ Notifier.signup_confirm(user, user.tokens.create).deliver_now
+ flash[:notice] = t "user.confirm_resend.success", :email => user.email
end
redirect_to :action => "login"
##
#
def unconfirmed_login(user)
+ session[:token] = user.tokens.create.token
+
redirect_to :action => "confirm", :display_name => user.display_name
session.delete(:remember_me)
end
def test_confirm_resend_success
+ session[:token] = users(:inactive_user).tokens.create.token
+
assert_difference "ActionMailer::Base.deliveries.size", 1 do
get :confirm_resend, :display_name => users(:inactive_user).display_name
end
ActionMailer::Base.deliveries.clear
end
- def test_confirm_resend_failure
+ def test_confirm_resend_no_token
+ assert_no_difference "ActionMailer::Base.deliveries.size" do
+ get :confirm_resend, :display_name => users(:inactive_user).display_name
+ end
+
+ assert_response :redirect
+ assert_redirected_to login_path
+ assert_match "User Inactive User not found.", flash[:error]
+ end
+
+ def test_confirm_resend_unknown_user
assert_no_difference "ActionMailer::Base.deliveries.size" do
get :confirm_resend, :display_name => "No Such User"
end