phoseum-cli 0.0.21 → 0.0.26

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: 518b20606af6427165c3a508202ebc7a3f3197414d0fed8e561c04073ca73a57
4
+ data.tar.gz: 87f76b684309ac2562bf0701697eb8dd69102402bbfbaad47dd767abde726379
5
5
  SHA512:
6
- metadata.gz: f25658cea0878061423c1761a5017fcbc4e78535bbce0175266539732f7eb862db30342d7a7276e182a71461548f021112c460c8d253dabc5624d17bc2597285
7
- data.tar.gz: 7cd9478c899d770e8cb15e1d83f1e0a030783ac3f5f10bdf99d2e8c046588001c77818b9d6abeb900fa2b979fa9bd47f87427f2305db0074d4cd501b4daabb77
6
+ metadata.gz: c7e46c70b62722c149beee38cc23c7fc3427b5fdf555e59ceca41097c58e767d9d7eb24eefb453b74efb3bd988d0580b485268146d111328d0556cfb5f55288e
7
+ data.tar.gz: 799ead2525025953ebd93c7c07c4c6444bcaca50b1b2d4ace245af45333b41b4e5d4e18dae92ef0d73f79784c29f77a459dda0c31a305ca9cd0978dca1da956f
@@ -25,6 +25,7 @@ client_checks
25
25
 
26
26
  def upload(album,syn_name='',description='')
27
27
  headers = {}
28
+
28
29
  if !validate_token($config['TOKEN'])
29
30
  if token = user_login()
30
31
  headers = { "bearer" => token }
@@ -204,14 +205,13 @@ def health(what='',name='')
204
205
 
205
206
  if list['success']
206
207
  data=list['success']
207
-
208
208
  if data['Albums']
209
209
  puts " >> Albums Available at this level (#{data['Albums'].count})".green if !$QUIET
210
210
  data['Albums'].each do |album|
211
211
  if $DEBUG
212
212
  puts JSON.pretty_generate(album)
213
213
  else
214
- created = DateTime.strptime(album['created'],'%s')
214
+ created = DateTime.strptime(album['created'].to_s,'%s')
215
215
  puts "Name: #{album['name']} | Web Path: #{album['web_path']} | description: #{album['description']} | created: #{created} "
216
216
  end
217
217
  end
@@ -223,8 +223,9 @@ def health(what='',name='')
223
223
  if $DEBUG
224
224
  puts JSON.pretty_generate(photo)
225
225
  else
226
- added = DateTime.strptime(photo['added'],'%s')
227
- puts "Name: #{photo['name']} | Filename: #{photo['image']} | Format: #{photo['full_info']['format']} | Dim.(WxH): #{photo['full_info']['geometry']['width']} x #{photo['full_info']['geometry']['height']} | Size: #{photo['size']} | Included: #{added}"
226
+ added = DateTime.strptime(photo['added'].to_s,'%s')
227
+ photo['exif']=JSON.parse(photo['exif'])
228
+ puts "Name: #{photo['name']} | Filename: #{photo['image']} | Format: #{photo['exif']['format']} | Dim.(WxH): #{photo['exif']['geometry']['width']} x #{photo['exif']['geometry']['height']} | Size: #{photo['size']} | Included: #{added}"
228
229
  end
229
230
  end
230
231
  end
@@ -237,45 +238,6 @@ def health(what='',name='')
237
238
  exit 0
238
239
  end
239
240
 
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
241
  def user_login(puser='',ppass='')
280
242
 
281
243
  server_value = cross_versions()
@@ -388,6 +350,17 @@ case options
388
350
  end
389
351
  health(what,value)
390
352
  when -> (cre) { cre[:create_user] }
353
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
354
+ if secretinfo['error']
355
+ err_msg = JSON.parse(secretinfo)
356
+ puts err_msg['error'].red
357
+ puts "You will only be able to change your own password.".red
358
+ exit 1
359
+ end
360
+ if secretinfo['success']
361
+ puts secretinfo['success'].green
362
+ end
363
+
391
364
  if options[:create_user]
392
365
  value=check_string_sanity(options[:create_user])
393
366
  username_sanity(value)
@@ -401,15 +374,18 @@ case options
401
374
  new_password=STDIN.getpass('Password: ')
402
375
  print "\t"
403
376
  confirm=STDIN.getpass('Confirm: ')
404
- password_sanity(new_password)
405
377
  if new_password == confirm
406
- if add_user(value,new_password,options[:role])
378
+ password_sanity(new_password)
379
+ if add_user(value,confirm,options[:role])
407
380
  puts "User #{value} added successfully".green
408
381
  exit 0
409
382
  else
410
383
  puts "Failed to add User #{value}".red
411
384
  exit 1
412
- end
385
+ end
386
+ else
387
+ puts "Passwords won't match, aborting. #{new_password} != #{confirm}".red
388
+ exit 1
413
389
  end
414
390
  end
415
391
  end
@@ -451,7 +427,7 @@ case options
451
427
  if options[:user]
452
428
  what='user'
453
429
  value=options[:user]
454
- secretinfo = api_caller({"action" => "check-secret"},true)
430
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
455
431
  if secretinfo['error']
456
432
  err_msg = JSON.parse(secretinfo)
457
433
  puts err_msg['error'].red
@@ -493,7 +469,7 @@ case options
493
469
  puts "Current user is #{auth_user}".green
494
470
  end
495
471
 
496
- secretinfo = api_caller({"action" => "check-secret"},true)
472
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
497
473
  if secretinfo['error']
498
474
  err_msg = JSON.parse(secretinfo)
499
475
  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.26"
@@ -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,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.21
4
+ version: 0.0.26
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-24 00:00:00.000000000 Z
11
+ date: 2020-11-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml