58 lines
1.1 KiB
Ruby
58 lines
1.1 KiB
Ruby
# -*- encoding : utf-8 -*-
|
|
class Admin::AdminAuthsController < ApplicationController
|
|
layout "connexion"
|
|
before_filter :auth_admin, :only => :index
|
|
|
|
|
|
|
|
def new_site
|
|
if session[:new_layout]
|
|
session[:new_layout] = nil
|
|
else
|
|
session[:new_layout] = true
|
|
|
|
end
|
|
|
|
if session[:past_layout]
|
|
session[:past_layout] = nil
|
|
else
|
|
session[:past_layout] = true
|
|
|
|
end
|
|
redirect_to :back
|
|
end
|
|
|
|
def index
|
|
redirect_to admin_i_tasks_path
|
|
end
|
|
|
|
def new
|
|
end
|
|
|
|
def create
|
|
user = Admin.find_by_login(params[:login])
|
|
|
|
|
|
if user && user.authenticate(params[:password])
|
|
|
|
if params[:remember_me]
|
|
cookies.permanent[:admin_remember_token] = user.remember_token
|
|
else
|
|
cookies[:admin_remember_token] = user.remember_token
|
|
end
|
|
|
|
|
|
redirect_to "/admin", notice: "Vous êtes connecté !"
|
|
else
|
|
flash.now.alert = "Email ou mot de passe incorect"
|
|
render "new"
|
|
end
|
|
end
|
|
|
|
def destroy
|
|
cookies.delete(:admin_remember_token)
|
|
|
|
redirect_to "/", notice: "Vous êtes déconnecté."
|
|
end
|
|
end
|