Sha256: 658be45f3a560a90f03c20bb04cc49f889b233d25ba7c6302ae43c15268bd905
Contents?: true
Size: 934 Bytes
Versions: 8
Compression:
Stored size: 934 Bytes
Contents
module OpenStax::Connect class SessionsOmniauthAuthenticated lev_handler protected def setup @auth_data = request.env['omniauth.auth'] end def authorized? @auth_data.provider == "openstax" end def handle outputs[:connect_user_to_sign_in] = user_to_sign_in end def user_to_sign_in return caller if !caller.nil? && !caller.is_anonymous? && caller.openstax_uid == @auth_data.uid existing_user = User.where(openstax_uid: @auth_data.uid).first return existing_user if !existing_user.nil? new_user = User.create do |user| user.openstax_uid = @auth_data.uid user.username = @auth_data.info.username user.first_name = @auth_data.info.first_name user.last_name = @auth_data.info.last_name end transfer_errors_from(new_user, {type: :verbatim}) new_user end end end
Version data entries
8 entries across 8 versions & 1 rubygems