Module: Driftrock::Service::DriftrockApp
- Defined in:
- lib/driftrock-service/driftrock_app.rb
Instance Method Summary collapse
- #authorise ⇒ Object
- #driftrock_app_status ⇒ Object
- #driftrock_logout ⇒ Object
- #should_authorise? ⇒ Boolean
- #token_for(timestamp, company_id) ⇒ Object
Instance Method Details
#authorise ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/driftrock-service/driftrock_app.rb', line 4 def return unless = params[:timestamp] company_id= params[:company_id] token = params[:token] expected_token = token_for(, company_id) if token != expected_token redirect_to Driftrock::Service::Config.website_location + "?unauthorised=true" else session[:user_id] = params[:user_id] session[:company_id] = params[:company_id] end end |
#driftrock_app_status ⇒ Object
33 34 35 |
# File 'lib/driftrock-service/driftrock_app.rb', line 33 def driftrock_app_status render text: "OK" end |
#driftrock_logout ⇒ Object
37 38 39 40 |
# File 'lib/driftrock-service/driftrock_app.rb', line 37 def driftrock_logout reset_session redirect_to Config.website_location+"/logout" end |
#should_authorise? ⇒ Boolean
19 20 21 22 23 24 25 |
# File 'lib/driftrock-service/driftrock_app.rb', line 19 def has_auth_params = params[:timestamp] && params[:company_id] && params[:token] has_session_data = defined?(session) && session[:user_id] && session[:company_id] has_auth_params || !has_session_data end |