Class: Brightcontent::SessionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/brightcontent/sessions_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#index

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
# File 'app/controllers/brightcontent/sessions_controller.rb', line 9

def create
  user = Brightcontent.user_model.find_by_email(params[:email])
  if user && user.authenticate(params[:password])
    session[:brightcontent_user_id] = user.id
    redirect_to root_url
  else
    flash.now[:danger] = "Email or password is invalid"
    render :new
  end
end

#destroyObject



20
21
22
23
# File 'app/controllers/brightcontent/sessions_controller.rb', line 20

def destroy
  session[:brightcontent_user_id] = nil
  redirect_to root_url
end

#newObject



5
6
7
# File 'app/controllers/brightcontent/sessions_controller.rb', line 5

def new
  redirect_to root_url if current_user
end