Class: TypusController
- Includes:
- SslRequirement, Typus::Authentication, Typus::Locale, Typus::QuickEdit, Typus::Reloader
- Defined in:
- app/controllers/typus_controller.rb
Instance Method Summary collapse
- #dashboard ⇒ Object
- #recover_password ⇒ Object
-
#reset_password ⇒ Object
Available if Typus::Configuration.options is enabled.
- #sign_in ⇒ Object
- #sign_out ⇒ Object
- #sign_up ⇒ Object
Methods included from Typus::Reloader
Methods included from Typus::QuickEdit
Methods included from Typus::Locale
Instance Method Details
#dashboard ⇒ Object
38 39 40 |
# File 'app/controllers/typus_controller.rb', line 38 def dashboard flash[:notice] = _("There are not defined applications in config/typus/*.yml.") if Typus.applications.empty? end |
#recover_password ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/controllers/typus_controller.rb', line 63 def recover_password if request.post? if user = Typus.user_class.find_by_email(params[:user][:email]) ActionMailer::Base.[:host] = request.host_with_port TypusMailer.deliver_reset_password_link(user) flash[:success] = _("Password recovery link sent to your email.") redirect_to admin_sign_in_path else redirect_to admin_recover_password_path end end end |
#reset_password ⇒ Object
Available if Typus::Configuration.options is enabled.
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'app/controllers/typus_controller.rb', line 79 def reset_password @user = Typus.user_class.find_by_token!(params[:token]) if request.post? @user.password = params[:user][:password] @user.password_confirmation = params[:user][:password_confirmation] if @user.save session[:typus_user_id] = @user.id redirect_to admin_dashboard_path else render :action => 'reset_password' end end end |
#sign_in ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'app/controllers/typus_controller.rb', line 42 def sign_in redirect_to admin_sign_up_path and return if Typus.user_class.count.zero? if request.post? if user = Typus.user_class.authenticate(params[:user][:email], params[:user][:password]) session[:typus_user_id] = user.id redirect_to params[:back_to] || admin_dashboard_path else flash[:error] = _("The email and/or password you entered is invalid.") redirect_to admin_sign_in_path end end end |
#sign_out ⇒ Object
58 59 60 61 |
# File 'app/controllers/typus_controller.rb', line 58 def sign_out session[:typus_user_id] = nil redirect_to admin_sign_in_path end |
#sign_up ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 |
# File 'app/controllers/typus_controller.rb', line 93 def sign_up redirect_to admin_sign_in_path and return unless Typus.user_class.count.zero? if request.post? email, password = params[:user][:email], 'columbia' user = Typus.user_class.generate(email, password) if user.save session[:typus_user_id] = user.id flash[:notice] = _("Password set to \"{{password}}\".", :password => password) redirect_to admin_dashboard_path else flash[:error] = _("That doesn't seem like a valid email address.") end else flash[:notice] = _("Enter your email below to create the first user.") end end |