devise-stormpath 0.2.0 → 0.2.1
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.
- data/app/controllers/devise/stormpath_confirmations_controller.rb +9 -0
- data/app/views/devise/registrations/new.html.erb +30 -0
- data/app/views/devise/sessions/new.html.erb +17 -0
- data/config/locales/en.yml +4 -1
- data/devise-stormpath.gemspec +1 -1
- data/lib/devise/models/stormpath_confirmable.rb +44 -0
- data/lib/devise/stormpath/routes.rb +6 -1
- data/lib/devise/stormpath/version.rb +1 -1
- data/lib/devise-stormpath.rb +1 -0
- data/spec/devise/models/stormpath_confirmable_spec.rb +25 -0
- metadata +11 -12
@@ -0,0 +1,30 @@
|
|
1
|
+
<h2>Sign up</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div><%= f.label :email %><br />
|
7
|
+
<%= f.email_field :email, :autofocus => true %></div>
|
8
|
+
|
9
|
+
<div><%= f.label :username %><br />
|
10
|
+
<%= f.text_field :username %></div>
|
11
|
+
|
12
|
+
<div><%= f.label :given_name %><br />
|
13
|
+
<%= f.text_field :given_name %></div>
|
14
|
+
|
15
|
+
<div><%= f.label :middle_name %><br />
|
16
|
+
<%= f.text_field :middle_name %></div>
|
17
|
+
|
18
|
+
<div><%= f.label :surname %><br />
|
19
|
+
<%= f.text_field :surname %></div>
|
20
|
+
|
21
|
+
<div><%= f.label :password %><br />
|
22
|
+
<%= f.password_field :password %></div>
|
23
|
+
|
24
|
+
<div><%= f.label :password_confirmation %><br />
|
25
|
+
<%= f.password_field :password_confirmation %></div>
|
26
|
+
|
27
|
+
<div><%= f.submit "Sign up" %></div>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<%= render "devise/shared/links" %>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<h2>Sign in</h2>
|
2
|
+
|
3
|
+
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
|
4
|
+
<div><%= f.label :username %><br />
|
5
|
+
<%= f.text_field :username, :autofocus => true %></div>
|
6
|
+
|
7
|
+
<div><%= f.label :password %><br />
|
8
|
+
<%= f.password_field :password %></div>
|
9
|
+
|
10
|
+
<% if devise_mapping.rememberable? -%>
|
11
|
+
<div><%= f.check_box :remember_me %> <%= f.label :remember_me %></div>
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
<div><%= f.submit "Sign in" %></div>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<%= render "devise/shared/links" %>
|
data/config/locales/en.yml
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#TODO Customize messages
|
2
|
-
|
3
2
|
en:
|
4
3
|
devise:
|
5
4
|
stormpath_passwords:
|
@@ -8,3 +7,7 @@ en:
|
|
8
7
|
updated_not_active: 'Your password was changed successfully.'
|
9
8
|
send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
|
10
9
|
no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
|
10
|
+
stormpath_confirmations:
|
11
|
+
confirmed: "Your account was successfully confirmed. You are now signed in."
|
12
|
+
send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
|
13
|
+
send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
|
data/devise-stormpath.gemspec
CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.require_paths = ["lib"]
|
18
18
|
|
19
19
|
s.add_dependency('devise')
|
20
|
-
s.add_dependency('stormpath-rails', '
|
20
|
+
s.add_dependency('stormpath-rails', '>= 0.4.3')
|
21
21
|
s.add_dependency('activesupport')
|
22
22
|
|
23
23
|
s.add_development_dependency('rake', '~> 10.0.2')
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Devise
|
2
|
+
module Models
|
3
|
+
module StormpathConfirmable
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
def self.required_fields(klass)
|
7
|
+
[:confirmation_token]
|
8
|
+
end
|
9
|
+
|
10
|
+
included do
|
11
|
+
attr_accessible :confirmation_token
|
12
|
+
attr_accessor :confirmation_token
|
13
|
+
end
|
14
|
+
|
15
|
+
def confirmed?
|
16
|
+
status != "UNVERIFIED"
|
17
|
+
end
|
18
|
+
|
19
|
+
def active_for_authentication?
|
20
|
+
super && confirmed?
|
21
|
+
end
|
22
|
+
|
23
|
+
def inactive_message
|
24
|
+
!confirmed? ? :unconfirmed : super
|
25
|
+
end
|
26
|
+
|
27
|
+
protected
|
28
|
+
|
29
|
+
module ClassMethods
|
30
|
+
def confirm_by_token(token)
|
31
|
+
begin
|
32
|
+
raise RuntimeError.new "Verification token required" unless token
|
33
|
+
account = ::Stormpath::Rails::Client.verify_account_email(token)
|
34
|
+
return self.where(stormpath_url: account.get_href).first
|
35
|
+
rescue RuntimeError => error
|
36
|
+
u = self.new
|
37
|
+
u.errors[:base] << error.message
|
38
|
+
u
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -5,4 +5,9 @@ ActionDispatch::Routing::Mapper.class_eval do
|
|
5
5
|
resource :password, :only => [:new, :create, :edit, :update],
|
6
6
|
:path => mapping.path_names[:password], :controller => controllers[:stormpath_passwords]
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
|
+
def devise_confirmation(mapping, controllers)
|
10
|
+
resource :confirmation, :only => [:show],
|
11
|
+
:path => mapping.path_names[:confirmation], :controller => controllers[:stormpath_confirmations]
|
12
|
+
end
|
13
|
+
end
|
data/lib/devise-stormpath.rb
CHANGED
@@ -9,3 +9,4 @@ Warden::Strategies.add(:stormpath_authenticatable, Devise::Strategies::Stormpath
|
|
9
9
|
|
10
10
|
Devise.add_module(:stormpath_authenticatable, :route => :session, :strategy => true, :controller => :sessions, :model => 'devise/models/stormpath_authenticatable')
|
11
11
|
Devise.add_module(:stormpath_recoverable, :route => :password, :controller => :stormpath_passwords, :model => 'devise/models/stormpath_recoverable')
|
12
|
+
Devise.add_module(:stormpath_confirmable, :route => :confirmation, :controller => :stormpath_confirmations, :model => 'devise/models/stormpath_confirmable')
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "devise/models/stormpath_confirmable"
|
3
|
+
|
4
|
+
describe Devise::Models::StormpathConfirmable do
|
5
|
+
class User
|
6
|
+
def self.attr_accessible(*args)
|
7
|
+
end
|
8
|
+
|
9
|
+
include Devise::Models::StormpathConfirmable
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:base) { mock("base") }
|
13
|
+
let(:errors) { mock("errors", :[] => base) }
|
14
|
+
let(:user) { mock("user", errors: errors) }
|
15
|
+
|
16
|
+
describe "::confirm_by_token" do
|
17
|
+
let(:account) { mock("account", get_href: "user href") }
|
18
|
+
|
19
|
+
it "should verify confirmation token at Stormpath and return user if verification passed" do
|
20
|
+
Stormpath::Rails::Client.should_receive(:verify_account_email).with("token").and_return(account)
|
21
|
+
User.should_receive(:where).with(stormpath_url: "user href").and_return([user])
|
22
|
+
User.confirm_by_token("token").should == user
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devise-stormpath
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-02-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: devise
|
@@ -32,17 +32,17 @@ dependencies:
|
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
33
33
|
none: false
|
34
34
|
requirements:
|
35
|
-
- -
|
35
|
+
- - ! '>='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 0.4.
|
37
|
+
version: 0.4.3
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
41
41
|
none: false
|
42
42
|
requirements:
|
43
|
-
- -
|
43
|
+
- - ! '>='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.4.
|
45
|
+
version: 0.4.3
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: activesupport
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -136,17 +136,22 @@ files:
|
|
136
136
|
- LICENSE
|
137
137
|
- README.md
|
138
138
|
- Rakefile
|
139
|
+
- app/controllers/devise/stormpath_confirmations_controller.rb
|
139
140
|
- app/controllers/devise/stormpath_passwords_controller.rb
|
141
|
+
- app/views/devise/registrations/new.html.erb
|
142
|
+
- app/views/devise/sessions/new.html.erb
|
140
143
|
- config/locales/en.yml
|
141
144
|
- devise-stormpath.gemspec
|
142
145
|
- lib/devise-stormpath.rb
|
143
146
|
- lib/devise/models/stormpath_authenticatable.rb
|
147
|
+
- lib/devise/models/stormpath_confirmable.rb
|
144
148
|
- lib/devise/models/stormpath_recoverable.rb
|
145
149
|
- lib/devise/stormpath/rails.rb
|
146
150
|
- lib/devise/stormpath/routes.rb
|
147
151
|
- lib/devise/stormpath/version.rb
|
148
152
|
- lib/devise/strategies/stormpath_authenticatable.rb
|
149
153
|
- spec/devise/models/stormpath_authenticatable_spec.rb
|
154
|
+
- spec/devise/models/stormpath_confirmable_spec.rb
|
150
155
|
- spec/devise/models/stormpath_recoverable_spec.rb
|
151
156
|
- spec/spec_helper.rb
|
152
157
|
- spec/support/client.rb
|
@@ -163,18 +168,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
163
168
|
- - ! '>='
|
164
169
|
- !ruby/object:Gem::Version
|
165
170
|
version: '0'
|
166
|
-
segments:
|
167
|
-
- 0
|
168
|
-
hash: 434371363033819234
|
169
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
170
172
|
none: false
|
171
173
|
requirements:
|
172
174
|
- - ! '>='
|
173
175
|
- !ruby/object:Gem::Version
|
174
176
|
version: '0'
|
175
|
-
segments:
|
176
|
-
- 0
|
177
|
-
hash: 434371363033819234
|
178
177
|
requirements: []
|
179
178
|
rubyforge_project:
|
180
179
|
rubygems_version: 1.8.24
|