Class: Adminpanel::SessionsController

Inherits:
ActionController::Base
  • Object
show all
Includes:
SessionsHelper
Defined in:
app/controllers/adminpanel/sessions_controller.rb

Instance Method Summary collapse

Methods included from SessionsHelper

#current_user, #current_user=, #sign_in, #sign_out, #signed_in?

Instance Method Details

#createObject



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

def create
  user = User.find_by_email(params[:session][:email].downcase)
  if user && user.authenticate(params[:session][:password])
     user
    flash[:success] = I18n.t('authentication.signin_success')
    redirect_to root_url
  else
    flash.now[:error] = I18n.t('authentication.signin_error')
    render 'new'
  end
end

#destroyObject



23
24
25
26
# File 'app/controllers/adminpanel/sessions_controller.rb', line 23

def destroy
  sign_out
  redirect_to 
end

#instagram_callbackObject



38
39
40
41
42
43
# File 'app/controllers/adminpanel/sessions_controller.rb', line 38

def instagram_callback
  response = Instagram.get_access_token(params[:code], :redirect_uri => instagram_callback_sessions_url)
  username = Instagram.client(access_token: response.access_token).user.username
  Auth.create(key: 'instagram', value: response.access_token, name: "@#{username}")
  redirect_to instagram_analytics_path
end

#instagram_loginObject



34
35
36
# File 'app/controllers/adminpanel/sessions_controller.rb', line 34

def 
  redirect_to Instagram.authorize_url(:redirect_uri => instagram_callback_sessions_url, :scope => 'comments')
end

#newObject



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

def new
end

#twitter_callbackObject



28
29
30
31
32
# File 'app/controllers/adminpanel/sessions_controller.rb', line 28

def twitter_callback
  save_twitter_tokens
  flash[:success] = I18n.t('twitter.saved_token')
  redirect_to twitter_analytics_path
end