sinatra_warden 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sinatra_warden/sinatra.rb +4 -2
- data/sinatra_warden.gemspec +2 -2
- data/spec/fixtures/basic_strategy.rb +1 -1
- data/spec/fixtures/testing_login.rb +11 -2
- data/spec/fixtures/user.rb +1 -1
- data/spec/sinatra_warden_spec.rb +37 -5
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
@@ -20,9 +20,11 @@ module Sinatra
|
|
20
20
|
alias_method :current_user, :user
|
21
21
|
|
22
22
|
# Set the currently logged in user
|
23
|
+
# Usage: self.user = @user
|
24
|
+
#
|
23
25
|
# @params [User] the user you want to log in
|
24
|
-
def user=(
|
25
|
-
warden.set_user
|
26
|
+
def user=(new_user)
|
27
|
+
warden.set_user(new_user)
|
26
28
|
end
|
27
29
|
alias_method :current_user=, :user=
|
28
30
|
|
data/sinatra_warden.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{sinatra_warden}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Justin Smestad", "Daniel Neighman"]
|
12
|
-
s.date = %q{2009-11-
|
12
|
+
s.date = %q{2009-11-05}
|
13
13
|
s.description = %q{basic helpers and authentication methods for using warden with sinatra also providing some hooks into Rack::Flash}
|
14
14
|
s.email = %q{justin.smestad@gmail.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -11,14 +11,23 @@ class TestingLogin < Sinatra::Base
|
|
11
11
|
"My Dashboard"
|
12
12
|
end
|
13
13
|
|
14
|
+
get '/warden' do
|
15
|
+
authorize!
|
16
|
+
"#{warden}"
|
17
|
+
end
|
18
|
+
|
19
|
+
get '/check_login' do
|
20
|
+
logged_in? ? "Hello Moto" : "Get out!"
|
21
|
+
end
|
22
|
+
|
14
23
|
get '/account' do
|
15
24
|
authorize!
|
16
25
|
"#{user.email}'s account page"
|
17
26
|
end
|
18
27
|
|
19
|
-
post '/login_as
|
28
|
+
post '/login_as' do
|
20
29
|
authorize!
|
21
|
-
user = User.authenticate(params['email'], params['password'])
|
30
|
+
self.user = User.authenticate(params['email'], params['password'])
|
22
31
|
end
|
23
32
|
|
24
33
|
get '/admin' do
|
data/spec/fixtures/user.rb
CHANGED
data/spec/sinatra_warden_spec.rb
CHANGED
@@ -76,21 +76,53 @@ describe "Sinatra::Warden" do
|
|
76
76
|
|
77
77
|
end
|
78
78
|
|
79
|
-
context "the authenticated? helper" do
|
79
|
+
context "the logged_in/authenticated? helper" do
|
80
|
+
before(:each) do
|
81
|
+
post '/login', 'email' => 'justin.smestad@gmail.com', 'password' => 'thedude'
|
82
|
+
last_request.env['warden'].authenticated?.should == true
|
83
|
+
end
|
80
84
|
|
81
|
-
it "should be aliased as logged_in?"
|
85
|
+
it "should be aliased as logged_in?" do
|
86
|
+
get '/check_login'
|
87
|
+
last_response.body.should == "Hello Moto"
|
88
|
+
end
|
82
89
|
|
83
|
-
it "should return
|
90
|
+
it "should return false when a user is not authenticated" do
|
91
|
+
get '/logout'
|
92
|
+
last_request.env['warden'].authenticated?.should == false
|
84
93
|
|
85
|
-
|
94
|
+
get '/check_login'
|
95
|
+
last_response.body.should == "Get out!"
|
96
|
+
end
|
86
97
|
|
87
98
|
end
|
88
99
|
|
89
100
|
context "the warden helper" do
|
101
|
+
before(:each) do
|
102
|
+
post '/login', 'email' => 'justin.smestad@gmail.com', 'password' => 'thedude'
|
103
|
+
last_request.env['warden'].authenticated?.should == true
|
104
|
+
end
|
90
105
|
|
91
|
-
it "returns the environment variables from warden"
|
106
|
+
it "returns the environment variables from warden" do
|
107
|
+
get '/warden'
|
108
|
+
last_response.body.should_not be_nil
|
109
|
+
end
|
92
110
|
|
93
111
|
end
|
94
112
|
end
|
95
113
|
|
114
|
+
context "Rack::Flash integration" do
|
115
|
+
|
116
|
+
it "should return a success message" do
|
117
|
+
post '/login', 'email' => 'justin.smestad@gmail.com', 'password' => 'thedude'
|
118
|
+
last_request.env['rack.session'][:__FLASH__][:success].should == "You have logged in successfully."
|
119
|
+
end
|
120
|
+
|
121
|
+
it "should return an error message" do
|
122
|
+
post '/login', 'email' => 'bad', 'password' => 'wrong'
|
123
|
+
last_request.env['rack.session'][:__FLASH__][:error].should == "Could not log you in."
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
96
128
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sinatra_warden
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Justin Smestad
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-11-
|
13
|
+
date: 2009-11-05 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|