thincloud-authentication 0.6.0 → 0.6.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/README.md +1 -0
- data/app/controllers/thincloud/authentication/passwords_controller.rb +1 -0
- data/app/models/thincloud/authentication/identity.rb +17 -1
- data/app/services/thincloud/authentication/create_invitation_for_user.rb +3 -1
- data/app/views/thincloud/authentication/passwords/edit.html.erb +7 -0
- data/lib/thincloud/authentication/version.rb +1 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -7,6 +7,8 @@ module Thincloud::Authentication
|
|
7
7
|
|
8
8
|
validates :name, presence: true
|
9
9
|
validates :email, presence: true, uniqueness: true, format: /@/
|
10
|
+
validates :password, presence: { if: :password_required? },
|
11
|
+
confirmation: { if: :password_required? }
|
10
12
|
|
11
13
|
# Ensure that a `verification_token` exists for new records.
|
12
14
|
after_initialize do
|
@@ -15,7 +17,7 @@ module Thincloud::Authentication
|
|
15
17
|
|
16
18
|
# Only validate password if the 'provider' is 'identity'.
|
17
19
|
before_validation do
|
18
|
-
self.password_digest = 0 unless
|
20
|
+
self.password_digest = 0 unless identity_provider?
|
19
21
|
end
|
20
22
|
|
21
23
|
# Public: Use a helpful attribute name when displaying errors.
|
@@ -88,5 +90,19 @@ module Thincloud::Authentication
|
|
88
90
|
self.password_reset_sent_at = Time.zone.now
|
89
91
|
save!
|
90
92
|
end
|
93
|
+
|
94
|
+
# Public: Determine if the provider is 'identity'
|
95
|
+
#
|
96
|
+
# Returns: true or false
|
97
|
+
def identity_provider?
|
98
|
+
provider == "identity"
|
99
|
+
end
|
100
|
+
|
101
|
+
# Public: Determine if the password must be provided
|
102
|
+
#
|
103
|
+
# Returns: true or false
|
104
|
+
def password_required?
|
105
|
+
identity_provider? && password_reset_token.blank?
|
106
|
+
end
|
91
107
|
end
|
92
108
|
end
|
@@ -4,8 +4,10 @@ module Thincloud::Authentication
|
|
4
4
|
class CreateInvitationForUser
|
5
5
|
|
6
6
|
def self.call(user, params)
|
7
|
+
password = SecureRandom.uuid
|
7
8
|
identity = Identity.create!(user: user, name: params[:name],
|
8
|
-
email: params[:email],
|
9
|
+
email: params[:email], password: password,
|
10
|
+
password_confirmation: password)
|
9
11
|
Identity.verify!(identity.verification_token)
|
10
12
|
identity.generate_password_token!
|
11
13
|
InvitationsMailer.new_invitation(identity.id).deliver
|
@@ -2,6 +2,13 @@
|
|
2
2
|
<fieldset>
|
3
3
|
<legend>Password Reset</legend>
|
4
4
|
|
5
|
+
<% if alert.present? %>
|
6
|
+
<div class="alert alert-block alert-error">
|
7
|
+
<h4><i class="icon-warning-sign"></i> Error</h4>
|
8
|
+
<%= alert %>
|
9
|
+
</div>
|
10
|
+
<% end %>
|
11
|
+
|
5
12
|
<div class="control-group">
|
6
13
|
<%= f.label :password, "Password", class: "control-label" %>
|
7
14
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thincloud-authentication
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-05-
|
13
|
+
date: 2013-05-15 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -150,7 +150,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
150
|
version: '0'
|
151
151
|
segments:
|
152
152
|
- 0
|
153
|
-
hash:
|
153
|
+
hash: -3125374884034061561
|
154
154
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
155
155
|
none: false
|
156
156
|
requirements:
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
version: '0'
|
160
160
|
segments:
|
161
161
|
- 0
|
162
|
-
hash:
|
162
|
+
hash: -3125374884034061561
|
163
163
|
requirements: []
|
164
164
|
rubyforge_project:
|
165
165
|
rubygems_version: 1.8.23
|