softwear-lib 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 46309929f4ab433f39e2249d28c52de5083e9c0c
4
- data.tar.gz: 214c83ab78624f336433d4ea95c12664a0b1de47
3
+ metadata.gz: df335f36b039e01cffdcfc3383eefd57ade6211c
4
+ data.tar.gz: 85d03c23a947a194b8148385841007261bed41ce
5
5
  SHA512:
6
- metadata.gz: 6294137fd3a37d5881187f5bddeecc78a34a5dfe957f1aca785bc94454f9ec62f196ff88ed42712e6d1ac8b7b94825c5f5f17fb5fb63dcfba50fa20fc4e23d56
7
- data.tar.gz: e59c12a9c183fb7fb1de46f33d9741bb2f9b6c5b5b0299c0330ea00f3c89297bedeec5fc6cee311976d71766b62eee897d500f16bee62f2ca38ab4558033fedb
6
+ metadata.gz: 2abb795beff31832cd6145858e14272b840415abee52011d6b3f510e7f40ccd24080ec38003347083621e6fccdbc9e0b84c7dd2eb1c077f52bb66322820aac5e
7
+ data.tar.gz: 3e317d8d8fc9a83dd9a726ccb847b556bf5b2ee1d3033e1ce618e94f5b49e0d53565ef3ec5e0708109aa43092c948f29c58394f8aff0d4eec27a0ebedb6066e6
@@ -405,7 +405,7 @@ module Softwear
405
405
 
406
406
  REMOTE_ATTRIBUTES = [
407
407
  :id, :email, :first_name, :last_name,
408
- :profile_picture_url
408
+ :roles, :profile_picture_url
409
409
  ]
410
410
  REMOTE_ATTRIBUTES.each(&method(:attr_accessor))
411
411
 
@@ -466,6 +466,16 @@ module Softwear
466
466
  def valid_password?(pass)
467
467
  query("pass #{id} #{pass}") == 'yes'
468
468
  end
469
+
470
+ def role?(*wanted_roles)
471
+ return true if wanted_roles.empty?
472
+
473
+ if @roles.nil?
474
+ query("role #{id} #{wanted_roles.join(' ')}") == 'yes'
475
+ else
476
+ wanted_roles.any? { |r| @roles.include?(r) }
477
+ end
478
+ end
469
479
  end
470
480
  end
471
481
  end
@@ -1,5 +1,34 @@
1
1
  module Softwear
2
2
  module Auth
3
+ # =======================================================================
4
+ # In development, unless ENV['AUTH_SERVER'] is set, Softwear::Auth::Model is
5
+ # set to this StubbedModel. The StubbedModel does not contact the auth_server,
6
+ # and instead retrieves user info from config/users.yml, which assumes the
7
+ # following format:
8
+ =begin
9
+ ---
10
+ signed_in: nigel@annarbortees.com
11
+
12
+ users:
13
+ admin@softwearcrm.com:
14
+ first_name: Admin
15
+ last_name: User
16
+ roles:
17
+ - sales_manager
18
+
19
+ nigel@annarbortees.com:
20
+ first_name: Nigel
21
+ last_name: Baillie
22
+ roles:
23
+ - developer
24
+
25
+ ricky@annarbortees.com:
26
+ first_name: Ricky
27
+ last_name: Winowiecki
28
+ =end
29
+ # Changes in this .yml file will be reflected live, without restarting your
30
+ # server.
31
+ # =======================================================================
3
32
  class StubbedModel < Softwear::Auth::StandardModel
4
33
  class << self
5
34
  def raw_query(*)
@@ -1,5 +1,5 @@
1
1
  module Softwear
2
2
  module Lib
3
- VERSION = "1.7.1"
3
+ VERSION = "1.7.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: softwear-lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.1
4
+ version: 1.7.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nigel Baillie