Class: QAuthRubyClient::SessionsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- QAuthRubyClient::SessionsController
- Defined in:
- app/controllers/q_auth_ruby_client/sessions_controller.rb
Instance Method Summary collapse
Instance Method Details
#create_session ⇒ Object
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] (I18n.t("authentication.logged_in_successfully_heading"), I18n.t("authentication.logged_in_successfully_message"), :success) redirect_to default_redirect_url_after_sign_in else raise response["errors"]["name"] end end |
#sign_in ⇒ Object
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 sign_in if current_user if current_user.token_expired? update_user_profile_data_and_auth_token return else redirect_to redirect_url_after_sign_in return end else update_user_profile_data_and_auth_token return end end |
#sign_out ⇒ Object
33 34 35 36 37 38 39 |
# File 'app/controllers/q_auth_ruby_client/sessions_controller.rb', line 33 def sign_out ("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 |