Sha256: c6edd5f45a243d569cb633ba36011be21a8786c5ee77fb1acf2bc8bc2c506322
Contents?: true
Size: 1.1 KB
Versions: 14
Compression:
Stored size: 1.1 KB
Contents
module OpenStax module Accounts class SessionsCallback lev_handler protected def setup @auth_data = request.env['omniauth.auth'] end def authorized? @auth_data.provider == "openstax" end def handle # Don't worry if the account is logged in or not beforehand. # Just assume that they aren't. existing_account = Account.where(openstax_uid: @auth_data.uid).first return outputs[:account] = existing_account if !existing_account.nil? new_account = Account.create do |account| account.openstax_uid = @auth_data.uid account.username = @auth_data.info.nickname account.first_name = @auth_data.info.first_name account.last_name = @auth_data.info.last_name account.full_name = @auth_data.info.name account.title = @auth_data.info.title account.access_token = @auth_data.credentials.token end transfer_errors_from(new_account, {type: :verbatim}) outputs[:account] = new_account end end end end
Version data entries
14 entries across 14 versions & 1 rubygems