Class | LoginController
In: | app/controllers/login_controller.rb
Parent: | ApplicationController

### Methods

add_user delete_user index list_users login logout

### Public Instance methods

add_user()

[Source]

        # File app/controllers/login_controller.rb, line 4
     4:   def add_user
     5:     @user = User.new(params[:user])
     6:     if request.post? and @user.save
     7:       flash.now[:notice] = "Utworzono konto użytkownika #{@user.name}"
     8:       @user = User.new
     9:     end
    10:   end

delete_user()

[Source]

        # File app/controllers/login_controller.rb, line 35
    35:   def delete_user
    36:     if request.post?
    37:       user = User.find(params[:id])
    38:       begin
    39:         user.destroy
    40:         flash[:notice] = "Użytkownik #{user.name} został usunięty"
    41:       rescue Exception => e
    42:         flash[:notice] = e.message
    43:       end
    44:     end
    45:     redirect_to(:action => :list_users)
    46:   end

index()

[Source]

        # File app/controllers/login_controller.rb, line 31
    31:   def index
    32:     @total_orders = Order.count
    33:   end

list_users()

[Source]

        # File app/controllers/login_controller.rb, line 48
    48:   def list_users
    49:     @all_users = User.find(:all)
    50:   end

login()

[Source]

        # File app/controllers/login_controller.rb, line 12
    12:   def login
    13:     session[:user_id] = nil
    14:     if request.post?
    15:       user = User.authenticate(params[:name], params[:password])
    16:       if user
    17:         session[:user_id] = user.id
    18:         redirect_to(:action => "index")
    19:       else
    20:         flash[:notice] = "Nieprawidłowy login lub hasło"
    21:       end
    22:     end
    23:   end

logout()

[Source]

        # File app/controllers/login_controller.rb, line 25
    25:   def logout
    26:     session[:user_id] = nil
    27:     flash[:notice] = "Wylogowano pomyślnie"
    28:     redirect_to(:action => "login")
    29:   end

[Validate]