Method: App42::User::UserService#authenticate
- Defined in:
- lib/user/UserService.rb
#authenticate(uName, pwd) ⇒ Object
Authenticate user based on userName and password
if authentication fails or username/password is blank or null
350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/user/UserService.rb', line 350 def authenticate(uName, pwd) puts "authenticateUser Called " puts "Base url #{@base_url}" response,usr = nil usr, util = User.new, Util.new util.throwExceptionIfNullOrBlank(uName, "UserName") util.throwExceptionIfNullOrBlank(pwd, "Password") begin connection = App42::Connection::RESTConnection.new(@base_url) body = {'app42' => {"user"=> { "userName" => uName, "password" => pwd }}}.to_json puts "Body #{body}" query_params = {} params = { 'apiKey'=> @api_key, 'version' => @version, 'timeStamp' => util., } query_params = params.clone params.store("body", body) signature = util.sign(@secret_key, params) resource_url = "#{@version}/#{@resource}/authenticate" response = connection.post(signature, resource_url, query_params, body) user = UserResponseBuilder.new usr = user.buildResponse(response) rescue App42Exception =>e raise e rescue Exception => e raise e end return usr end |