Sha256: a25f98d70442e76e8ada89aa5f886176ac5d5b67a184bd34556318309c421f20

Contents?: true

Size: 1.49 KB

Versions: 12

Compression:

Stored size: 1.49 KB

Contents

class Admin::AccountController < Admin::BaseController

  layout 'admin/session'

  skip_before_filter :reload_config_and_roles
  skip_before_filter :authenticate
  skip_before_filter :set_locale

  before_filter :sign_in?, :except => [:forgot_password, :send_password, :show]
  before_filter :new?, :only => [:forgot_password, :send_password]

  def new
    flash[:notice] = Typus::I18n.t("Enter your email below to create the first user.")
  end

  def create
    user = Typus.user_class.generate(:email => params[:typus_user][:email])
    redirect_to user ? { :action => "show", :id => user.token } : { :action => :new }
  end

  def forgot_password
  end

  def send_password
    if user = Typus.user_class.find_by_email(params[:typus_user][:email])
      url = admin_account_url(user.token)
      Admin::Mailer.reset_password_link(user, url).deliver
      redirect_to new_admin_session_path, :notice => Typus::I18n.t("Password recovery link sent to your email.")
    else
      render :action => :forgot_password
    end
  end

  def show
    flash[:notice] = Typus::I18n.t("Please set a new password.")
    typus_user = Typus.user_class.find_by_token!(params[:id])
    session[:typus_user_id] = typus_user.id
    redirect_to params[:return_to] || { :controller => "/admin/#{Typus.user_class.to_resource}", :action => "edit", :id => typus_user.id }
  end

  private

  def sign_in?
    redirect_to new_admin_session_path unless zero_users
  end

  def new?
    redirect_to new_admin_account_path if zero_users
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
typus-3.1.0.rc18 app/controllers/admin/account_controller.rb
typus-3.1.0.rc17 app/controllers/admin/account_controller.rb
typus-3.1.0.rc16 app/controllers/admin/account_controller.rb
typus-3.1.0.rc15 app/controllers/admin/account_controller.rb
typus-3.1.0.rc14 app/controllers/admin/account_controller.rb
typus-3.1.0.rc13 app/controllers/admin/account_controller.rb
typus-3.1.0.rc12 app/controllers/admin/account_controller.rb
typus-3.1.0.rc11 app/controllers/admin/account_controller.rb
typus-3.1.0.rc10 app/controllers/admin/account_controller.rb
typus-3.1.0.rc9 app/controllers/admin/account_controller.rb
typus-3.1.0.rc8 app/controllers/admin/account_controller.rb
typus-3.1.0.rc7 app/controllers/admin/account_controller.rb