Sha256: a612bf6256296ad9c784254e1e656bb3dc5a1b74bca79c8a8dc7c1bb0f9f439a
Contents?: true
Size: 1.14 KB
Versions: 1
Compression:
Stored size: 1.14 KB
Contents
class AccountsController < ApplicationController before_filter :verify_users, :only => [:login] def login case request.method when :post if user = User.authenticate(params[:user_login], params[:user_password]) session[:user_id] = user.id flash[:notice] = "Login successful" cookies[:is_admin] = "yes" redirect_back_or_default :controller => "admin/dashboard", :action => "index" else flash.now[:notice] = "Login unsuccessful" @login = params[:user_login] end end end def signup unless User.count.zero? redirect_to :action => 'login' return end @user = User.new(params[:user]) if request.post? and @user.save session[:user_id] = @user.id flash[:notice] = "Signup successful" redirect_to :controller => "admin/settings", :action => "index" return end end def logout session[:user_id] = nil cookies.delete :is_admin end def welcome end private def verify_users if User.count == 0 redirect_to :controller => "accounts", :action => "signup" else true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
typo-5.0.2 | app/controllers/accounts_controller.rb |