phoseum-cli 0.0.18 → 0.0.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ae7c5b87f964e094e8e1e6ef6f1a147e5870aead7c9e8d8fbc1f301f9801f4b
4
- data.tar.gz: d495df08338bfb6a067fdc2643e0a12042a310ba4b83d4b5476bf900123c4949
3
+ metadata.gz: '092592a7b73a29fb773b199b9e29f7054da0da5701583c1162c2500a1860635f'
4
+ data.tar.gz: fc71817a9eb49a14d2567694efaa91ee076e991a1780b8abdbf20b3a2c2032db
5
5
  SHA512:
6
- metadata.gz: 40c22cc7fff4bfec7b5479856b5ec2b6ea95089f538f4bce1dcc5f394bf0f90c61245ac5249f103183bf283d97772a856f99bddb669fef3ba9a00db1541a4b11
7
- data.tar.gz: 220f37e7d4efaf40014a025a4cd4250726d5e0d9752994a35636dfab51be8ecca3acccc1758471ec43c7eb7774ff88b261b2a86dc0722c40cd239a61bc3c1cd0
6
+ metadata.gz: 78a80cda0d947299a0b95b86f2ccebcf1df4d263bdad641ff0d0aec8d3e2445a28d2062ba52f49d520bf334051448adcf02674069992f7b55d22e1eb60e9f288
7
+ data.tar.gz: 2b296a8c6ab2f30de4e7c85dd0b9acf55a3c5b8130ed9887c359220da14879d2b73895894b29f450c4b4a390f04edae6473fe317874183284d336066ddaac3cb
@@ -341,7 +341,6 @@ def user_login(puser='',ppass='')
341
341
  return false
342
342
  end
343
343
 
344
-
345
344
  def delete(what='',path='')
346
345
  if !validate_token($config['TOKEN'])
347
346
  if token = user_login()
@@ -461,15 +460,23 @@ case options
461
460
  end
462
461
  when -> (o) { o[:options] }
463
462
  if options[:user]
464
- print "Please confirm #{options[:user]} password.\n\t"
465
- current_password=STDIN.getpass('Password: ')
466
- if token = user_login(options[:user],current_password)
467
- print "\n Change [P]assword, [U]sername, [R]ole :[P/U/R]: "
468
- confirm=STDIN.gets.chomp
469
- else
470
- puts "User Check Failed".red
463
+ tokeninfo = api_caller({"action" => "token-payload", "token" => "#{$config['TOKEN']}"})
464
+ if tokeninfo['error']
465
+ puts "Your token seems invalid, please login again".red
471
466
  exit 1
472
467
  end
468
+ if tokeninfo['success']
469
+ puts tokeninfo.payload
470
+ end
471
+ # print "Please confirm #{options[:user]} password.\n\t"
472
+ # current_password=STDIN.getpass('Password: ')
473
+ # if token = user_login(options[:user],current_password)
474
+ # print "\n Change [P]assword, [U]sername, [R]ole :[P/U/R]: "
475
+ # confirm=STDIN.gets.chomp
476
+ # else
477
+ # puts "User Check Failed".red
478
+ # exit 1
479
+ # end
473
480
  else
474
481
  # if !what
475
482
  puts "Got no user to work with. Exiting.".red
@@ -261,6 +261,35 @@ def validate_token(token)
261
261
  end
262
262
  end
263
263
 
264
+ def api_caller(json_body)
265
+ headers = {}
266
+ if $config['TOKEN']
267
+ headers={ "bearer" => "#{$config['TOKEN']}" }
268
+ else
269
+ return false
270
+ end
271
+ base = URI.parse("#{$config['SERVERURL']}")
272
+ request = Net::HTTP::Post.new(base,headers)
273
+ request.body = JSON.generate(json_body)
274
+ response = Net::HTTP.start(base.hostname, $config['PORT'],
275
+ :timeout => $config['CALL_TIMEOUT'],
276
+ :use_ssl => base.scheme == "https",
277
+ :verify_mode => OpenSSL::SSL::VERIFY_PEER,
278
+ :ca_file => $config['CA_TRUST']
279
+ ) do |http|
280
+ http.request(request)
281
+ end
282
+ begin
283
+ list = JSON.parse(response.body)
284
+ return list
285
+ rescue
286
+ puts "\nThe server sent out an Error:".red
287
+ puts clean_html(response.body)
288
+ exit 1
289
+ end
290
+ end
291
+
292
+
264
293
  def cross_versions
265
294
  headers = {}
266
295
  base = URI.parse("#{$config['SERVERURL']}")
@@ -291,7 +320,6 @@ def cross_versions
291
320
  end
292
321
  end
293
322
 
294
-
295
323
  def delete_user(username)
296
324
  headers = {}
297
325
  if $config['TOKEN']
@@ -330,4 +358,4 @@ def local_version
330
358
  return
331
359
  end
332
360
 
333
- VERSION_SIGN="0.0.18"
361
+ VERSION_SIGN="0.0.19"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoseum-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.18
4
+ version: 0.0.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julio C Hegedus
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2020-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml