Class: TypusController

Inherits:
ApplicationController
  • Object
show all
Includes:
SslRequirement, Typus::Authentication, Typus::Locale, Typus::QuickEdit, Typus::Reloader
Defined in:
app/controllers/typus_controller.rb

Instance Method Summary collapse

Methods included from Typus::Reloader

#reload_config_et_roles

Methods included from Typus::QuickEdit

#quick_edit

Methods included from Typus::Locale

#set_locale

Instance Method Details

#dashboardObject



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_passwordObject



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.default_url_options[:host] = request.host_with_port
      TypusMailer.deliver_reset_password_link(user)
      flash[:success] = _("Password recovery link sent to your email.")
      redirect_to 
    else
      redirect_to admin_recover_password_path
    end
  end
end

#reset_passwordObject

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_inObject



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'app/controllers/typus_controller.rb', line 42

def 

  redirect_to  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 
    end
  end

end

#sign_outObject



58
59
60
61
# File 'app/controllers/typus_controller.rb', line 58

def sign_out
  session[:typus_user_id] = nil
  redirect_to 
end

#sign_upObject



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 

  redirect_to  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