Class: Adminpanel::SessionsController
- Inherits:
-
ActionController::Base
- Object
- ActionController::Base
- Adminpanel::SessionsController
show all
- Includes:
- SessionsHelper
- Defined in:
- app/controllers/adminpanel/sessions_controller.rb
Instance Method Summary
collapse
#current_user, #current_user=, #sign_in, #sign_out, #signed_in?
Instance Method Details
#create ⇒ Object
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])
sign_in 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
|
#destroy ⇒ Object
23
24
25
26
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 23
def destroy
sign_out
redirect_to signin_path
end
|
#instagram_callback ⇒ Object
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_login ⇒ Object
34
35
36
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 34
def instagram_login
redirect_to Instagram.authorize_url(:redirect_uri => instagram_callback_sessions_url, :scope => 'comments')
end
|
#new ⇒ Object
8
9
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 8
def new
end
|
28
29
30
31
32
|
# File 'app/controllers/adminpanel/sessions_controller.rb', line 28
def
flash[:success] = I18n.t('twitter.saved_token')
redirect_to
end
|