Class: Obscured::Doorman::Providers::GitHub::Strategy

Inherits:
Warden::Strategies::Base
  • Object
show all
Defined in:
lib/obscured-doorman/providers/github/strategy.rb

Instance Method Summary collapse

Instance Method Details

#authenticate!Object



24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/obscured-doorman/providers/github/strategy.rb', line 24

def authenticate!
  user = Doorman::User.where(:username.in => GitHub.configuration[:token].emails).first

  if user.nil?
    fail!(Doorman::MESSAGES[:login_bad_credentials])
  elsif !user.confirmed
    user.confirm

    fail!(Doorman::MESSAGES[:login_not_confirmed])
  else
    success!(user)
  end
end

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/obscured-doorman/providers/github/strategy.rb', line 11

def valid?
  emails = GitHub.configuration[:token].emails

  if GitHub.configuration[:domains].nil?
    return true if emails.length.positive?
  else
    return true if valid_domain?
  end

  fail!(GitHub::MESSAGES[:invalid_domain])
  false
end