Class: Brightcontent::SessionsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#default_url_options, #index

Instance Method Details

#createObject



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

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

#destroyObject



22
23
24
25
# File 'app/controllers/brightcontent/sessions_controller.rb', line 22

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

#newObject



7
8
9
# File 'app/controllers/brightcontent/sessions_controller.rb', line 7

def new
  redirect_to root_url if current_user
end