Module: Guestlist::ClassMethods

Defined in:
lib/guestlist.rb

Instance Method Summary collapse

Instance Method Details

#authenticate(login, token) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/guestlist.rb', line 5

def authenticate(, token)
  attributes = {:login => , :encrypted_token => encrypt(token)}

  if user = ()
    return user if user.encrypted_token == attributes[:encrypted_token]
  end

  if Github.fetch(, token)
    user.update_attributes(attributes) if user
    user || User.create!(attributes)
  end
end