Class: QAuthRubyClient::SessionsController

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

Instance Method Summary collapse

Instance Method Details

#create_sessionObject



21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/q_auth_ruby_client/sessions_controller.rb', line 21

def create_session
  response = QAuthRubyClient::User.create_session(params[:auth_token])
  if response.is_a?(QAuthRubyClient::User)
    @current_user = response
    session[:id] = @current_user.q_auth_uid unless session[:id]
    set_notification_messages(I18n.t("authentication.logged_in_successfully_heading"), I18n.t("authentication.logged_in_successfully_message"), :success)
    redirect_to 
  else
    raise response["errors"]["name"]
  end
end

#sign_inObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/q_auth_ruby_client/sessions_controller.rb', line 6

def 
  if current_user
    if current_user.token_expired?
      
      return
    else
      redirect_to 
      return
    end
  else
    
    return
  end
end

#sign_outObject



33
34
35
36
37
38
39
# File 'app/controllers/q_auth_ruby_client/sessions_controller.rb', line 33

def sign_out
  set_flash_message("You have successfully signed out", :notice)
  # Reseting the auth token for user when he logs out.
  # @current_user.update_attribute :auth_token, SecureRandom.hex
  session.delete(:id)
  redirect_to default_redirect_url_after_sign_out
end