Class: Adminpanel::SessionsController

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

Instance Method Summary collapse

Methods included from ApplicationHelper

#adminpanel_form_for, #full_title, #is_current_section?, #link_to_add_fields, #main_root_path, #route_symbol, #symbol_class

Methods included from SharedPagesHelper

#active_tab, #belong_to_object_name, #class_name_downcase, #demodulize_class, #field_value, #get_oauth_link, #is_customized_field?, #pluralize_model, #relationship_ids, #table_type

Methods included from BreadcrumbsHelper

#breadcrumb_add, #render_breadcrumb

Methods included from SessionsHelper

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

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/adminpanel/sessions_controller.rb', line 15

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')
    permission = user.role.permissions.first
    if permission.nil?
      redirect_to root_url
    else
      redirect_to [route_symbol(permission.resource)]
    end
  else
    flash.now[:error] = I18n.t('authentication.signin_error')
    render 'new'
  end
end

#destroyObject



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

def destroy
  sign_out
  redirect_to 
end

#instagram_callbackObject



41
42
43
44
45
46
# File 'app/controllers/adminpanel/sessions_controller.rb', line 41

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



37
38
39
# File 'app/controllers/adminpanel/sessions_controller.rb', line 37

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

#newObject



12
13
# File 'app/controllers/adminpanel/sessions_controller.rb', line 12

def new
end