Skip to content

Commit 8b6697b

Browse files
committed
Rename using_password? to already_using_password?
Except on the User drop for liquid templates
1 parent 746bec2 commit 8b6697b

File tree

9 files changed

+12
-12
lines changed

9 files changed

+12
-12
lines changed

app/controllers/provider/admin/user/personal_details_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def user_params
3030
end
3131

3232
def current_password_verification
33-
return true unless current_user.using_password?
33+
return true unless current_user.already_using_password?
3434

3535
unless current_user.authenticated?(user_params[:current_password])
3636
flash.now[:danger] = t('.wrong')

app/controllers/provider/passwords_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class Provider::PasswordsController < FrontendController
77
before_action :passwords_allowed?
88

99
def new
10-
return redirect_back_or_to(root_path), danger: t('.has_password') if current_user.using_password?
10+
return redirect_back_or_to(root_path), danger: t('.has_password') if current_user.already_using_password?
1111

1212
reset_session_password_token
1313
token = current_user.generate_lost_password_token

app/lib/authentication/by_password.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,12 +78,12 @@ def update_password(new_password, new_password_confirmation)
7878
save
7979
end
8080

81-
def using_password?
81+
def already_using_password?
8282
password_digest_in_database.present?
8383
end
8484

8585
def can_set_password?
86-
account.password_login_allowed? && !using_password?
86+
account.password_login_allowed? && !already_using_password?
8787
end
8888

8989
def special_fields

app/views/provider/admin/user/personal_details/edit.html.slim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ div class="pf-c-card"
1818
required: false,
1919
input_html: { value: '', type: 'password', required: false }
2020

21-
- if current_user.using_password?
21+
- if current_user.already_using_password?
2222
= form.inputs "Provide your current password and update your personal details" do
2323
= form.input :current_password, as: :patternfly_input,
2424
required: true,

lib/developer_portal/app/controllers/developer_portal/admin/account/personal_details_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def user_params
5050
end
5151

5252
def verify_current_password
53-
return unless current_user.using_password?
53+
return unless current_user.already_using_password?
5454
return if current_user.authenticated?(user_params[:current_password])
5555

5656
resource.errors.add(:current_password, t('activerecord.errors.models.user.current_password_incorrect'))

lib/developer_portal/lib/liquid/drops/user.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def invitation
9393

9494
desc "Returns true if user signed up with password"
9595
def using_password?
96-
@user.using_password?
96+
@user.already_using_password?
9797
end
9898

9999
desc %{

test/functional/partners/providers_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ def provider_params
9494
user = assigns(:user)
9595
assert user.valid?
9696
assert_nil user.password_digest, 'User should have no password when not provided'
97-
assert_not user.using_password?, 'User should not be using password'
97+
assert_not user.already_using_password?, 'User should not be using password'
9898

9999
body = JSON.parse(response.body)
100100
assert_equal true, body['success']

test/functional/partners/users_controller_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def setup
6262

6363
assert user.valid?
6464
assert_nil user.password_digest, 'User should have no password when not provided'
65-
assert_not user.using_password?, 'User should not be using password'
65+
assert_not user.already_using_password?, 'User should not be using password'
6666
assert_equal "sso-id", user.open_id
6767

6868
body = JSON.parse(response.body)

test/unit/authentication/by_password_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,20 +275,20 @@ class UsingPasswordTest < MethodsTest
275275

276276
test 'returns true when password is persisted in database' do
277277
assert @user.password_digest_in_database.present?
278-
assert @user.using_password?
278+
assert @user.already_using_password?
279279
end
280280

281281
test 'returns false when password_digest is nil in database' do
282282
@user.update_column(:password_digest, nil)
283283

284-
assert_not @user.using_password?
284+
assert_not @user.already_using_password?
285285
end
286286

287287
test 'returns false when password is set but not yet persisted' do
288288
new_user = @buyer.users.build(username: 'newuser', email: 'new@example.com', password: 'testpassword', password_confirmation: 'testpassword')
289289

290290
assert new_user.password_digest.present?
291-
assert_not new_user.using_password?
291+
assert_not new_user.already_using_password?
292292
end
293293
end
294294
end

0 commit comments

Comments
 (0)