A corporation manager and dashboard for EVE Online
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

users_controller.rb 1.2 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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[:username].blank? || params[:password].blank?
  11. flash.now[:alert] = 'Both a character name and password are required.'
  12. render 'login' and return
  13. end
  14. user = User.find_by(name: params[:username])
  15. if user.nil? || !user.authenticate(params[:password])
  16. flash.now[:alert] = 'Incorrect character name or password.'
  17. render 'login' and return
  18. end
  19. allow_non_corp = AdminSettings.get_bool(:allow_non_corp)
  20. if !allow_non_corp && !user.in_corp? && !user.admin?
  21. corp_name = AdminSettings.get_bool(: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. # do user logout logic
  34. redirect_to root_url
  35. end
  36. end
  37. def reset
  38. if request.post?
  39. # do user reset logic
  40. end
  41. end
  42. end