Sha256: 542e557ce61efe5de4da3615832587420cfe3db75df9ad4f96aebc1c1dca2e68
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
class AccountController < Spree::BaseController before_filter :login_from_cookie layout 'admin' def index redirect_to(:action => 'signup') unless logged_in? || User.count > 0 end def login return unless request.post? self.current_user = User.authenticate(params[:login], params[:password]) if logged_in? if params[:remember_me] == "1" self.current_user.remember_me cookies[:auth_token] = { :value => self.current_user.remember_token , :expires => self.current_user.remember_token_expires_at } end redirect_back_or_default(:controller => 'store', :action => 'index') flash.now[:notice] = "Logged in successfully" else flash.now[:error] = "Login authentication failed." end end def signup @user = User.new(params[:user]) return unless request.post? @user.save! self.current_user = @user redirect_back_or_default(:controller => '/account', :action => 'index') flash[:notice] = "Thanks for signing up!" rescue ActiveRecord::RecordInvalid flash[:error] = "Problem creating user account." render :action => 'signup' end def logout self.current_user.forget_me if logged_in? cookies.delete :auth_token reset_session flash[:notice] = "You have been logged out." redirect_back_or_default('/') #redirect_back_or_default(:controller => '/account', :action => 'index') end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
spree-0.2.0 | app/controllers/account_controller.rb |