phoseum-cli 0.0.21 → 0.0.22

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: 3e2bd25792289a6beebdf3d17cb4b4365086d407348c4ca7e17862b65522f57d
4
- data.tar.gz: f4fbfa8dc826cfb429b15b3ccbc79446af45d6a44dbd99e01ce96ee77dfa15b6
3
+ metadata.gz: dda101298c10dfba931a42da89cf49f7621341ab94c6f6eb5b763d17abe36084
4
+ data.tar.gz: 3b60673f5aa9ace4862570622496360d83352d89407d9863cf4f2391ba73efb3
5
5
  SHA512:
6
- metadata.gz: f25658cea0878061423c1761a5017fcbc4e78535bbce0175266539732f7eb862db30342d7a7276e182a71461548f021112c460c8d253dabc5624d17bc2597285
7
- data.tar.gz: 7cd9478c899d770e8cb15e1d83f1e0a030783ac3f5f10bdf99d2e8c046588001c77818b9d6abeb900fa2b979fa9bd47f87427f2305db0074d4cd501b4daabb77
6
+ metadata.gz: 113d85253686c204b3eaa02643050193cdb7a65ea33e1654b7fa8da1c1e65f56b197db195c0f4cc9059f447a4781c18f5b48afce52dd5b7b36e23ff25657d6dd
7
+ data.tar.gz: 46efcbf1a8b7679f9c0888355ebc1963f047bc56ab079b9122f9e0050b84ab4162b6d4906066b4b213d8410b16c544475664ceed0fccb2a86bbb3948bedf8771
@@ -237,45 +237,6 @@ def health(what='',name='')
237
237
  exit 0
238
238
  end
239
239
 
240
- def user_mgmt(action,user,pass='',role='')
241
- post_body={}
242
- if action == "add_user"
243
- post_body=JSON.generate({"action" => "create-user", "user" => "#{user}", "password" => "#{pass}", "role" => "#{role}"})
244
- if !$config['DEFAULT_SECRET']
245
- puts "You must have a DEFAULT_SECRET setting to be able to create a user".red
246
- exit 1
247
- end
248
- end
249
- base = URI.parse("#{$config['SERVERURL']}")
250
- puts "\nConnecting to: #{$config['SERVERURL']}".yellow if !$QUIET
251
- request = Net::HTTP::Post.new(base)
252
- request.body = post_body
253
- request.basic_auth("auth", $config['DEFAULT_SECRET'])
254
- response = Net::HTTP.start(base.hostname, $config['PORT'],
255
- :timeout => $config['CALL_TIMEOUT'],
256
- :use_ssl => base.scheme == "https",
257
- :verify_mode => OpenSSL::SSL::VERIFY_PEER,
258
- :ca_file => $config['CA_TRUST']
259
- ) do |http|
260
- http.request(request)
261
- end
262
- begin
263
- list = JSON.parse(response.body)
264
- if list['error']
265
- puts list['error'].red
266
- exit 1
267
- end
268
- if list['success']
269
- data=list['success']
270
- puts data
271
- end
272
- rescue
273
- puts "Error on Login".red
274
- puts clean_html(response.body)
275
- end
276
- exit 0
277
- end
278
-
279
240
  def user_login(puser='',ppass='')
280
241
 
281
242
  server_value = cross_versions()
@@ -388,6 +349,17 @@ case options
388
349
  end
389
350
  health(what,value)
390
351
  when -> (cre) { cre[:create_user] }
352
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
353
+ if secretinfo['error']
354
+ err_msg = JSON.parse(secretinfo)
355
+ puts err_msg['error'].red
356
+ puts "You will only be able to change your own password.".red
357
+ exit 1
358
+ end
359
+ if secretinfo['success']
360
+ puts secretinfo['success'].green
361
+ end
362
+
391
363
  if options[:create_user]
392
364
  value=check_string_sanity(options[:create_user])
393
365
  username_sanity(value)
@@ -401,15 +373,18 @@ case options
401
373
  new_password=STDIN.getpass('Password: ')
402
374
  print "\t"
403
375
  confirm=STDIN.getpass('Confirm: ')
404
- password_sanity(new_password)
405
376
  if new_password == confirm
406
- if add_user(value,new_password,options[:role])
377
+ password_sanity(new_password)
378
+ if add_user(value,confirm,options[:role])
407
379
  puts "User #{value} added successfully".green
408
380
  exit 0
409
381
  else
410
382
  puts "Failed to add User #{value}".red
411
383
  exit 1
412
- end
384
+ end
385
+ else
386
+ puts "Passwords won't match, aborting. #{new_password} != #{confirm}".red
387
+ exit 1
413
388
  end
414
389
  end
415
390
  end
@@ -451,7 +426,7 @@ case options
451
426
  if options[:user]
452
427
  what='user'
453
428
  value=options[:user]
454
- secretinfo = api_caller({"action" => "check-secret"},true)
429
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
455
430
  if secretinfo['error']
456
431
  err_msg = JSON.parse(secretinfo)
457
432
  puts err_msg['error'].red
@@ -493,7 +468,7 @@ case options
493
468
  puts "Current user is #{auth_user}".green
494
469
  end
495
470
 
496
- secretinfo = api_caller({"action" => "check-secret"},true)
471
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
497
472
  if secretinfo['error']
498
473
  err_msg = JSON.parse(secretinfo)
499
474
  puts err_msg['error'].red
@@ -370,4 +370,4 @@ def local_version
370
370
  return
371
371
  end
372
372
 
373
- VERSION_SIGN="0.0.21"
373
+ VERSION_SIGN="0.0.22"
@@ -21,7 +21,6 @@ class String
21
21
  capital= false
22
22
  regular= false
23
23
  all_valid= true
24
- puts "Testing #{self}"
25
24
  n=self.split("")
26
25
  self.slice!(0..self.size)
27
26
  n.each { |b|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phoseum-cli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julio C Hegedus