Class: Omnigollum::Models::OmniauthUser
Instance Attribute Summary
Attributes inherited from User
#email, #name, #nickname, #provider, #uid
Instance Method Summary collapse
-
#initialize(hash, options) ⇒ OmniauthUser
constructor
A new instance of OmniauthUser.
Constructor Details
#initialize(hash, options) ⇒ OmniauthUser
Returns a new instance of OmniauthUser.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/omnigollum.rb', line 16 def initialize (hash, ) # Validity checks, don't trust providers @uid = hash['uid'].to_s.strip raise OmniauthUserInitError, "Insufficient data from authentication provider, uid not provided or empty" if @uid.empty? @name = hash['info']['name'].to_s.strip if hash['info'].has_key?('name') @name = [:default_name] if !@name || @name.empty? raise OmniauthUserInitError, "Insufficient data from authentication provider, name not provided or empty" if !@name || @name.empty? @email = hash['info']['email'].to_s.strip if hash['info'].has_key?('email') @email = [:default_email] if !@email || @email.empty? raise OmniauthUserInitError, "Insufficient data from authentication provider, email not provided or empty" if !@email || @email.empty? @nickname = hash['info']['nickname'].to_s.strip if hash['info'].has_key?('nickname') @provider = hash['provider'] self end |