shield-contrib 0.0.1 → 0.0.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.
@@ -1,8 +1,8 @@
1
1
  module Shield
2
2
  module Contrib
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
 
6
6
  autoload :Ohm, "shield/contrib/ohm"
7
7
  autoload :Sinatra, "shield/contrib/sinatra"
8
- end
8
+ end
@@ -14,7 +14,9 @@ module Shield
14
14
 
15
15
  module Fetch
16
16
  def fetch(email)
17
- find(:email => email).first
17
+ return if email.to_s.empty?
18
+
19
+ find(:email => email.downcase.strip).first
18
20
  end
19
21
  end
20
22
 
@@ -33,6 +35,10 @@ module Shield
33
35
  end
34
36
  end
35
37
 
38
+ def email
39
+ read_local(:email).to_s.downcase.strip
40
+ end
41
+
36
42
  def password=(password)
37
43
  unless password.to_s.empty?
38
44
  self.crypted_password = Shield::Password.encrypt(password)
@@ -6,8 +6,6 @@ module Shield
6
6
  m.set :shield_redirect_after_logout, "/"
7
7
  m.set :shield_auth_failure, "Wrong Username and/or Password combination."
8
8
 
9
- m.enable :sessions
10
-
11
9
  m.helpers Shield::Helpers
12
10
  m.helpers do
13
11
  def current_user
@@ -22,8 +20,8 @@ module Shield
22
20
  super
23
21
  end
24
22
 
25
- def logout(model = User)
26
- super
23
+ def authenticated?(model = User)
24
+ authenticated(model)
27
25
  end
28
26
  end
29
27
 
@@ -33,15 +31,15 @@ module Shield
33
31
 
34
32
  m.post "/login" do
35
33
  if login(User, params[:username], params[:password])
36
- redirect settings.shield_redirect_after_login
34
+ redirect_to_stored(settings.shield_redirect_after_login)
37
35
  else
38
36
  session[:error] = settings.shield_auth_failure
39
- redirect "/login"
37
+ redirect_to_login
40
38
  end
41
39
  end
42
40
 
43
41
  m.get "/logout" do
44
- logout
42
+ logout(User)
45
43
  redirect settings.shield_redirect_after_logout
46
44
  end
47
45
  end
@@ -1,8 +1,6 @@
1
1
  $:.unshift(File.expand_path("../lib", File.dirname(__FILE__)))
2
2
 
3
- puts "!! REMOVE THIS IN LINE: #{__LINE__} of #{__FILE__}"
4
- $:.unshift("/Users/cyx/Labs/shield/lib")
5
-
3
+ require "shield"
6
4
  require "shield/contrib"
7
5
  require "spawn"
8
6
  require "ohm"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 1
9
- version: 0.0.1
8
+ - 2
9
+ version: 0.0.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Michel Martens
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-10-21 00:00:00 +08:00
19
+ date: 2010-12-19 00:00:00 +08:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency