Sha256: 408344f3b9eeab3a996fc074cc43cac86b18129d430e65dd11227ae9ecbaaf1d

Contents?: true

Size: 492 Bytes

Versions: 4

Compression:

Stored size: 492 Bytes

Contents

class Session < MLS::Model

  belongs_to :account

  # Authenticate with email and password.
  # Returns either the newly created session or nil
  def self.authenticate(email, password=nil)
    if email.is_a? Hash
      password = email[:password]
      email = email[:email]
    end
    
    Session.create(:email => email, :password => password)
  rescue Sunstone::Exception::Unauthorized
    nil
  end

  def self.authenticate_by_token(token)
    Session.create(:token => token)
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mls-1.4.0 lib/mls/session.rb
mls-1.3.0 lib/mls/session.rb
mls-1.2.0 lib/mls/session.rb
mls-1.1.4 lib/mls/session.rb