lib/finapps/rest/sessions.rb in finapps-4.0.5 vs lib/finapps/rest/sessions.rb in finapps-4.0.6
- old
+ new
@@ -1,18 +1,23 @@
# frozen_string_literal: true
module FinApps
module REST
class Sessions < FinAppsCore::REST::Resources # :nodoc:
+ CONSUMER_LOGIN = 'login'
LOGOUT = 'logout'
def create(params, path = nil)
return super nil, path if path == LOGOUT
raise FinAppsCore::InvalidArgumentsError, 'Invalid argument: params.' unless validates params
- path ||= 'login'
+ path ||= CONSUMER_LOGIN
- super params, path
+ begin
+ super params, path
+ rescue FinAppsCore::ApiUnauthenticatedError
+ return [nil, ["Invalid #{path == CONSUMER_LOGIN ? 'Consumer' : 'Operator'} Identifier or Credentials"]]
+ end
end
def destroy
create nil, LOGOUT
end