pipa-authmagic 0.0.2 → 0.0.3

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.
@@ -3,6 +3,7 @@ require 'authmagic/rails/modules'
3
3
  class << ActionController::Base
4
4
  def authmagic(*modules, &block)
5
5
  context = Authmagic::Context.new(modules, :application_controller => self, &block)
6
- define_method(:security_context) { context }
6
+ metaclass.send(:define_method, :security_context) { context }
7
+ define_method(:security_context) { self.class.security_context }
7
8
  end
8
9
  end
@@ -24,7 +24,19 @@ module Authmagic
24
24
 
25
25
  session = @context.config.session
26
26
  @context.config.new_session_path ||= :"new_#{session}_path"
27
- @context.config.application_controller.send(:include, ApplicationControllerMethods)
27
+ context = @context
28
+ @context.config.application_controller.class_eval do
29
+ include ApplicationControllerMethods
30
+ bn = context.principal.name.underscore
31
+ unless bn == 'principal'
32
+ cp = "current_#{bn}"
33
+ cpid = "#{cp}_id"
34
+ private
35
+ alias_method cp, :current_principal
36
+ alias_method cpid, :current_principal_id
37
+ helper_method cp, cpid
38
+ end
39
+ end
28
40
  end
29
41
 
30
42
  module ContextMethods
@@ -97,7 +109,7 @@ module Authmagic
97
109
  p = security_context.principal.authenticate(
98
110
  login => options[login] || params[sess][login],
99
111
  password => options[password] || params[sess][password])
100
- session[:current_principal_id] = p.id
112
+ session[:current_principal_id], session[:current_principal] = p.id, p
101
113
  end
102
114
  end
103
115
  end
@@ -61,8 +61,8 @@ module Authmagic
61
61
  end
62
62
 
63
63
  define_method encryptor do |plaintext|
64
- hash = (digest = digest.new << send(salt) << plaintext).hexdigest
65
- stretches.times { hash = digest.hexdigest(hash) }
64
+ hash = (digest.new << send(salt) << plaintext).hexdigest
65
+ stretches.times { hash = (digest.new << hash).hexdigest }
66
66
  hash
67
67
  end
68
68
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pipa-authmagic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Igor Gunko
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-12-27 00:00:00 -08:00
12
+ date: 2008-12-28 00:00:00 -08:00
13
13
  default_executable:
14
14
  dependencies: []
15
15