Sha256: 9466bf07d3a54f8d54e63ecb929add3a1403f1934a3c2e56cde3fc16c369d488

Contents?: true

Size: 747 Bytes

Versions: 13

Compression:

Stored size: 747 Bytes

Contents

module Concen
  class SessionsController < ApplicationController
    layout "concen/application"

    def new
      if User.all.any?
        render
      else
        redirect_to new_concen_user_path
      end
    end

    def create
      user = User.where(:username => /#{params[:username]}/i).first

      if user && user.authenticate(params[:password])
        cookies.permanent[:auth_token] = user.auth_token
        redirect_to concen_root_path, :notice => "You have successfully signed in!"
      else
        flash.now.alert = "Invalid email or password"
        render "new"
      end
    end

    def destroy
      cookies.delete(:auth_token)
      redirect_to root_path, :notice => "You have successfully signed out!"
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
concen-0.2.7 app/controllers/concen/sessions_controller.rb
concen-0.2.6 app/controllers/concen/sessions_controller.rb
concen-0.2.5 app/controllers/concen/sessions_controller.rb
concen-0.2.4 app/controllers/concen/sessions_controller.rb
concen-0.2.3 app/controllers/concen/sessions_controller.rb
concen-0.2.2 app/controllers/concen/sessions_controller.rb
concen-0.2.1 app/controllers/concen/sessions_controller.rb
concen-0.2.0 app/controllers/concen/sessions_controller.rb
concen-0.1.7 app/controllers/concen/sessions_controller.rb
concen-0.1.6 app/controllers/concen/sessions_controller.rb
concen-0.1.5 app/controllers/concen/sessions_controller.rb
concen-0.1.4 app/controllers/concen/sessions_controller.rb
concen-0.1.3 app/controllers/concen/sessions_controller.rb