Class: Adminpanel::SessionsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Adminpanel::SessionsController
show all
- Includes:
- ApplicationHelper, SessionsHelper
- Defined in:
- app/controllers/adminpanel/sessions_controller.rb
Instance Method Summary
collapse
#adminpanel_form_for, #full_title, #is_current_section?, #link_to_add_fields, #main_root_path, #route_symbol, #symbol_class
#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
#breadcrumb_add, #render_breadcrumb
#current_user, #current_user=, #sign_in, #sign_out, #signed_in?
Instance Method Details
#create ⇒ Object
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])
sign_in 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
|
#destroy ⇒ Object
32
33
34
35
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 32
def destroy
sign_out
redirect_to signin_path
end
|
#instagram_callback ⇒ Object
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_login ⇒ Object
37
38
39
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 37
def instagram_login
redirect_to Instagram.authorize_url(redirect_uri: instagram_callback_sessions_url, scope: 'comments')
end
|
#new ⇒ Object
12
13
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 12
def new
end
|