A corporation manager and dashboard for EVE Online
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

users_controller.rb 1.3 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 = AdminSetting.get_bool(:allow_non_corp)
  20. if !allow_non_corp && !user.in_corp? && !user.admin?
  21. corp_name = AdminSetting.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. 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. end