Sha256: 2ed0d35057b115a35f85169786ea0873b55f4674ef9f5865d48742b69bb36841
Contents?: true
Size: 965 Bytes
Versions: 7
Compression:
Stored size: 965 Bytes
Contents
# frozen_string_literal: true require 'nsrr/helpers/json_request' module Nsrr module Helpers # Helper to verify that user is authenticated. class Authorization def self.get_token(token) puts ' Get your token here: ' + "#{Nsrr::WEBSITE}/token".colorize(:blue).on_white.underline puts ' Your input is hidden while entering token.'.colorize(:white) print ' Enter your token: ' token = STDIN.noecho(&:gets).chomp if token.to_s.strip == '' token.strip! (response, _status) = Nsrr::Helpers::JsonRequest.get("#{Nsrr::WEBSITE}/api/v1/account/profile.json", auth_token: token) if response.is_a?(Hash) && response['authenticated'] puts 'AUTHORIZED'.colorize(:green) + ' as ' + "#{response['first_name']} #{response['last_name']}".colorize(:white) else puts 'UNAUTHORIZED'.colorize(:red) + ' Public Access Only' end token end end end end
Version data entries
7 entries across 7 versions & 1 rubygems