Class: YourMembership::Sa::Auth

Inherits:
Base
  • Object
show all
Defined in:
lib/your_membership/sa_auth.rb

Overview

YourMembership System Administrator Member Authentication

Class Method Summary collapse

Methods inherited from Base

build_XML_request, new_call_id, post, response_to_array, response_to_array_of_hashes, response_valid?, response_ym_error?

Class Method Details

.authenticate(session, user_name, password = nil, password_hash = nil) ⇒ YourMembership::Member

Authenticates a member’s username and password and binds them to the current API session.

Parameters:

  • session (YourMembership::Session)
  • user_name (String)

    The Username of the user the session should be bound to.

  • password (String) (defaults to: nil)

    The Password (Optional) pf the specified user.

  • password_hash (String) (defaults to: nil)

    The Password Hash for the specified user which allows the system to perform actions on behalf of a user as if they were signed in without knowing the user’s cleartext password.

Returns:

See Also:



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/your_membership/sa_auth.rb', line 15

def self.authenticate(session, user_name, password = nil, password_hash = nil)
  options = {}
  options[:Username] = user_name
  options[:Password] = password if password
  options[:PasswordHash] = password_hash if password_hash

  response = post('/', :body => build_XML_request('Sa.Auth.Authenticate', session, options))

  response_valid? response
  if response['YourMembership_Response']['Sa.Auth.Authenticate']
    session.get_authenticated_user
  else
    return false
  end

  YourMembership::Member.create_from_session(session)
end