Guest User

Untitled

a guest
May 11th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. class UsersController < ApplicationController
  2.  
  3. # render new.rhtml
  4. def new
  5. @user = User.new
  6. end
  7.  
  8. def create
  9. logout_keeping_session!
  10. @user = User.new(params[:user])
  11. success = @user && @user.save
  12. if :password == :password_confirm
  13. if success && @user.errors.empty?
  14. # Protects against session fixation attacks, causes request forgery
  15. # protection if visitor resubmits an earlier form using back
  16. # button. Uncomment if you understand the tradeoffs.
  17. # reset session
  18. self.current_user = @user # !! now logged in
  19. redirect_back_or_default('/')
  20. flash[:notice] = "Thanks for signing up! We're sending you an email with your activation code."
  21. else
  22. flash[:error] = "We couldn't set up that account, sorry. Please try again, or contact an admin (link is above)."
  23. render :action => 'new'
  24. end
  25. else
  26. flash[:error] = "Your Passwords did not match"
  27. end
  28. end
  29. end
Add Comment
Please, Sign In to add comment