Module: Intra::Authentication
- Included in:
- SessionsController
- Defined in:
- lib/intra/authentication.rb
Class Method Summary collapse
Instance Method Summary collapse
- #authenticate! ⇒ Object
- #current_user ⇒ Object
- #handle_unverified_request ⇒ Object
- #intra_session ⇒ Object
- #sign_in(hash) ⇒ Object
- #sign_out ⇒ Object
- #signed_in? ⇒ Boolean
- #signed_out? ⇒ Boolean
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/intra/authentication.rb', line 3 def self.included(base) base.class_eval do if respond_to?(:helper_method) helper_method :current_user, :signed_in?, :signed_out? end private( :authenticate!, :current_user, :handle_unverified_request, :sign_in, :sign_out, :signed_in?, :signed_out? ) end end |
Instance Method Details
#authenticate! ⇒ Object
21 22 23 24 |
# File 'lib/intra/authentication.rb', line 21 def authenticate! Intra.logger.debug 'Intra::Authentication authenticate!' redirect_to Intra.sign_in_path unless signed_in? end |
#current_user ⇒ Object
26 27 28 |
# File 'lib/intra/authentication.rb', line 26 def current_user intra_session&.current_user end |
#handle_unverified_request ⇒ Object
49 50 51 52 |
# File 'lib/intra/authentication.rb', line 49 def handle_unverified_request super sign_out end |
#intra_session ⇒ Object
54 55 56 |
# File 'lib/intra/authentication.rb', line 54 def intra_session request.env[:intra] end |
#sign_in(hash) ⇒ Object
30 31 32 33 34 |
# File 'lib/intra/authentication.rb', line 30 def sign_in(hash) Intra.logger.debug 'Intra::Authentication sign_in' user = Intra.user_class.constantize.authenticate(hash) intra_session.sign_in user end |
#sign_out ⇒ Object
36 37 38 39 |
# File 'lib/intra/authentication.rb', line 36 def sign_out Intra.logger.debug 'Intra::Authentication sign_out' intra_session&.sign_out end |
#signed_in? ⇒ Boolean
41 42 43 |
# File 'lib/intra/authentication.rb', line 41 def signed_in? intra_session&.signed_in? end |
#signed_out? ⇒ Boolean
45 46 47 |
# File 'lib/intra/authentication.rb', line 45 def signed_out? intra_session&.signed_out? end |