ixtlan-user-management 0.1.1 → 0.1.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.
@@ -19,6 +19,7 @@
19
19
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  #
21
21
  require 'ixtlan/user_management/authentication_model'
22
+ require 'multi_json'
22
23
  module Ixtlan
23
24
  module UserManagement
24
25
  class Authenticator
@@ -34,7 +35,7 @@ module Ixtlan
34
35
  def login( username_or_email, password )
35
36
  user = nil
36
37
  @restserver.create( Authentication.new(:login => username_or_email, :password => password) ) do |json, req|
37
- user = user_new( JSON.load( json ) ) unless json.strip == ''
38
+ user = user_new( MultiJson.load( json ) ) unless json.strip == ''
38
39
  #tell restserver to ignore response
39
40
  nil
40
41
  end
@@ -18,7 +18,6 @@
18
18
  # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19
19
  # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20
20
  #
21
-
22
21
  module Ixtlan
23
22
  module UserManagement
24
23
 
@@ -72,17 +71,39 @@ module Ixtlan
72
71
  end
73
72
  end
74
73
 
75
- on get, :ping do
76
- self.class.authenticator.ping( current_user )
77
- head 200
74
+ on authenticated? do
75
+ on get, 'me' do
76
+ if current_user.respond_to? :updated_at
77
+ if modified_since.nil? || current_user.updated_at > modified_since
78
+ last_modified( current_user.updated_at )
79
+ browser_only_cache_no_store
80
+ write current_user, :use => :me
81
+ else
82
+ last_modified( modified_since )
83
+ end
84
+ else
85
+ browser_only_cache_no_store
86
+ write current_user, :use => :me
87
+ end
88
+ end
89
+
90
+ on get, 'ping' do
91
+ self.class.authenticator.ping( current_user )
92
+ head 200
93
+ end
78
94
  end
79
-
95
+
96
+ on get, /(me|ping)/ do
97
+ head :unauthorized
98
+ end
99
+
80
100
  on delete do
81
101
  self.class.authenticator.logout( current_user ) if current_user
82
102
  log "logout"
83
103
  reset_current_user
84
104
  head 200
85
105
  end
106
+
86
107
  end
87
108
  end
88
109
  end
@@ -48,7 +48,7 @@ module Ixtlan
48
48
  Group.new( g )
49
49
  end
50
50
  user = User.first( :login => data[ 'login' ] )
51
- user.groups = groups
51
+ user.groups = groups if user
52
52
  user
53
53
  end
54
54
  end
@@ -67,4 +67,4 @@ module Ixtlan
67
67
  end
68
68
  end
69
69
  end
70
- end
70
+ end
@@ -24,7 +24,7 @@ module Ixtlan
24
24
  class Session
25
25
  include Virtus
26
26
 
27
- attribute :idle_session_timeout, Integer
27
+ attribute :idle_session_timeout, Integer, :default => 30
28
28
  attribute :user, User
29
29
  attribute :permissions, Array[Object]
30
30
 
@@ -33,4 +33,4 @@ module Ixtlan
33
33
  end
34
34
  end
35
35
  end
36
- end
36
+ end
@@ -25,17 +25,17 @@ module Ixtlan
25
25
 
26
26
  root 'session'
27
27
 
28
- add_context(:single,
29
- :only => [:idle_session_timeout],
30
- :include => {
31
- :user => {
32
- },
33
- :permissions => {
34
- :include => [:actions, :associations]
35
- }
36
- }
37
- )
28
+ add_context( :single,
29
+ :only => [ :idle_session_timeout ],
30
+ :include => {
31
+ :user => {
32
+ :only => [ :id, :login, :name ]
33
+ },
34
+ :permissions => {
35
+ :include => [ :actions, :associations ]
36
+ }
37
+ } )
38
38
 
39
39
  end
40
40
  end
41
- end
41
+ end
metadata CHANGED
@@ -2,15 +2,31 @@
2
2
  name: ixtlan-user-management
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.1
5
+ version: 0.1.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Christian Meier
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-03-16 00:00:00.000000000 Z
12
+ date: 2013-03-22 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: multi_json
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.6'
21
+ none: false
22
+ requirement: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ none: false
28
+ prerelease: false
29
+ type: :runtime
14
30
  - !ruby/object:Gem::Dependency
15
31
  name: rake
16
32
  version_requirements: !ruby/object:Gem::Requirement