24
25
26
27
28
29
30
31
|
# File 'lib/crowd-client.rb', line 24
def login(username, password)
response = connection.post('session', :username => username, :password => password)
raise Exception::AuthenticationFailed.new if response.status == 400 && response.body['reason'] == 'INVALID_USER_AUTHENTICATION'
raise Exception::InactiveAccount.new if response.status == 400 && response.body['reason'] == 'INACTIVE_ACCOUNT'
raise Exception::UnknownError.new(response.body.to_s) if response.status != 201
return response.body['token']
end
|