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 CHANGED
@@ -16,6 +16,7 @@ This gem has been tested against the following Ruby versions:
16
16
 
17
17
  * MRI 1.9.2
18
18
  * MRI 1.9.3
19
+ * MRI 2.0.0
19
20
  * JRuby 1.6+ (with `JRUBY_OPTS=--1.9`)
20
21
  * Rubinius 2.0.0dev (with `RBXOPT=-X19`)
21
22
 
@@ -25,6 +25,7 @@ module Thincloud::Authentication
25
25
  login_as @identity.user
26
26
  redirect_to after_password_update_path
27
27
  else
28
+ flash.now[:alert] = "Unable to update password. Please try again."
28
29
  render :edit
29
30
  end
30
31
  end
@@ -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 provider == "identity"
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], password_digest: 0)
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
 
@@ -1,5 +1,5 @@
1
1
  module Thincloud
2
2
  module Authentication
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.1"
4
4
  end
5
5
  end
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.0
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-14 00:00:00.000000000 Z
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: 2368003791290441844
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: 2368003791290441844
162
+ hash: -3125374884034061561
163
163
  requirements: []
164
164
  rubyforge_project:
165
165
  rubygems_version: 1.8.23