A corporation manager and dashboard for EVE Online
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

users_controller.rb 1.4 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. class UsersController < ApplicationController
  2. def signup
  3. if request.post?
  4. # do user create logic
  5. redirect_to root_url
  6. end
  7. end
  8. def login
  9. if request.post?
  10. if params[:email].blank? || params[:password].blank?
  11. flash.now[:alert] = 'Both an email and a password are required.'
  12. render 'login' and return
  13. end
  14. user = User.find_by(email: params[:email])
  15. if user.nil? || !user.authenticate(params[:password])
  16. flash.now[:alert] = 'Incorrect email address or password.'
  17. render 'login' and return
  18. end
  19. allow_non_corp = AdminSetting.get_bool(:allow_non_corp)
  20. if !allow_non_corp && !user.in_corp? && !user.admin?
  21. corp_name = AdminSetting.get(:corp_name)
  22. flash[:alert] = "You are not a member of #{corp_name}, and access to "\
  23. "this site is disallowed for non-corp members."
  24. redirect_to root_url and return
  25. end
  26. session[:user_id] = user.id
  27. flash[:notice] = 'Login successful!'
  28. redirect_to root_url
  29. end
  30. end
  31. def logout
  32. if request.post?
  33. session.delete(:user_id)
  34. flash[:notice] = 'Logout successful!'
  35. redirect_to root_url
  36. end
  37. end
  38. def reset
  39. if request.post?
  40. # do user reset logic
  41. end
  42. end
  43. def settings
  44. if request.post?
  45. # do settings save logic
  46. end
  47. end
  48. end