Sha256: 935b245a0bfd763a57f30b1c0563241fe3349fea4073b7ba99d082fec5dbf260
Contents?: true
Size: 1.06 KB
Versions: 1
Compression:
Stored size: 1.06 KB
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.nickname user.first_name = @auth_data.info.first_name user.last_name = @auth_data.info.last_name user.full_name = @auth_data.info.name user.title = @auth_data.info.title user.access_token = @auth_data.credentials.token end transfer_errors_from(new_user, {type: :verbatim}) new_user end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openstax_connect-0.1.0 | app/handlers/openstax/connect/sessions_omniauth_authenticated.rb |