Sha256: db263b9dc5b519c49166236ea3a60961785335d4dcd52ccbc8887872bc0e5483

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 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 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

3 entries across 3 versions & 1 rubygems

Version Path
concen-0.1.2 app/controllers/concen/sessions_controller.rb
concen-0.1.1 app/controllers/concen/sessions_controller.rb
concen-0.1 app/controllers/concen/sessions_controller.rb