phoseum-cli 0.0.20 → 0.0.25

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: bfc9c3e5f01d6ea982796a580be0195b76156127ab1b39c3c1bfdb0d1ada4f21
4
- data.tar.gz: eb9e11b414ee5be39678593668f2fa8f02477e61b1cdbd85a0d69fbdf8728d6f
3
+ metadata.gz: 2661bcdb53adfc4d38701aca4eaa8cccc3738fd119f3a1da971d157bcf91f932
4
+ data.tar.gz: f1dd196b277efee399ae1af804a12350e23b8c1c06f023eb322306b9af11016a
5
5
  SHA512:
6
- metadata.gz: c433b128e7140e01364e04309bec935cf66efcfebe785ffbe7f4cefbf0dcdf007cb2f8f7f6398eb7fcae87c751fb7f4213110422b03d621120c991369277d8a6
7
- data.tar.gz: 1435d44fa6d8599e5ba9492fbce3bb5e30dba57e24c225f7ed6cbfd87ae56f7f3cca5820e9c94a7d259ca652e8875ec5ea503ebb1839969561cf99c5c5f28b7c
6
+ metadata.gz: 1d8ef28e22c329a13b78f2d5d9a4f476cd5d805828bb82e6681f4d41c17b720f26ea3c8bb3e05564084875b8db7b71b1e9af3ac26a756ded4f16841cf24503d2
7
+ data.tar.gz: 860e9fc1f0624c96f8c24b21429349d977dc27404e941f1f1e95a7b00537ed6c9a2b130c6d03c92dfdbaff30738ca2bb5c59f8aad05f7aadcdf7282a8919432a
@@ -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,13 +350,24 @@ case options
388
350
  end
389
351
  health(what,value)
390
352
  when -> (cre) { cre[:create_user] }
391
- puts "Creating User".green if !$QUIET
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
+
392
364
  if options[:create_user]
393
365
  value=check_string_sanity(options[:create_user])
394
366
  username_sanity(value)
367
+ puts "Creating User #{value}".green if !$QUIET
395
368
  what='add_user'
396
- if !options[:role]
397
- puts "You need to select one of the valid Roles".red
369
+ if !options[:role] || options[:role] != "Super" && options[:role] != "User"
370
+ puts "You need to select one of the valid Roles (Super or User)".red
398
371
  exit 1
399
372
  else
400
373
  print "Please type the password twice for user #{value}.\n\t"
@@ -403,7 +376,16 @@ case options
403
376
  confirm=STDIN.getpass('Confirm: ')
404
377
  if new_password == confirm
405
378
  password_sanity(new_password)
406
- user_mgmt(what,value,new_password,options[:role])
379
+ if add_user(value,confirm,options[:role])
380
+ puts "User #{value} added successfully".green
381
+ exit 0
382
+ else
383
+ puts "Failed to add User #{value}".red
384
+ exit 1
385
+ end
386
+ else
387
+ puts "Passwords won't match, aborting. #{new_password} != #{confirm}".red
388
+ exit 1
407
389
  end
408
390
  end
409
391
  end
@@ -445,7 +427,7 @@ case options
445
427
  if options[:user]
446
428
  what='user'
447
429
  value=options[:user]
448
- secretinfo = api_caller({"action" => "check-secret"},true)
430
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
449
431
  if secretinfo['error']
450
432
  err_msg = JSON.parse(secretinfo)
451
433
  puts err_msg['error'].red
@@ -487,7 +469,7 @@ case options
487
469
  puts "Current user is #{auth_user}".green
488
470
  end
489
471
 
490
- secretinfo = api_caller({"action" => "check-secret"},true)
472
+ secretinfo = api_caller({"action" => "check-secret", "value" => $config['DEFAULT_SECRET']},true)
491
473
  if secretinfo['error']
492
474
  err_msg = JSON.parse(secretinfo)
493
475
  puts err_msg['error'].red
@@ -534,7 +516,6 @@ case options
534
516
  if opt_action == "P"
535
517
  print "Please type new password for user #{user_work} .\n\t"
536
518
  new_password=STDIN.getpass('Password: ')
537
- puts "testing #{new_password}"
538
519
  print "\t"
539
520
  check_password=STDIN.getpass('Confirm: ')
540
521
  if new_password != check_password
@@ -312,6 +312,17 @@ def change_username(user,new_user)
312
312
  end
313
313
  end
314
314
 
315
+ def add_user(user,password,role)
316
+ result = api_caller({"action" => "create-user", "user" => user, "password" => password, "role" => role},true)
317
+ if result['error']
318
+ return false
319
+ end
320
+ if result['success']
321
+ return true
322
+ end
323
+ end
324
+
325
+
315
326
  def change_role(user,new_role)
316
327
  result = api_caller({"action" => "change-role", "username" => user, "new-role" => new_role},true)
317
328
  if result['error']
@@ -334,7 +345,7 @@ def password_sanity(password)
334
345
  end
335
346
 
336
347
  def username_sanity(username)
337
- if new_user.length < MIN_USER
348
+ if username.length < MIN_USER
338
349
  puts "New Username is shorter than #{MIN_USER} chars, please use a bigger username.".red
339
350
  exit 1
340
351
  end
@@ -359,4 +370,4 @@ def local_version
359
370
  return
360
371
  end
361
372
 
362
- VERSION_SIGN="0.0.20"
373
+ VERSION_SIGN="0.0.25"
@@ -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.20
4
+ version: 0.0.25
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-22 00:00:00.000000000 Z
11
+ date: 2020-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yaml