Skip to content

Commit 08d950c

Browse files
committed
Clean up more references to role
1 parent 0abd6df commit 08d950c

File tree

9 files changed

+14
-26
lines changed

9 files changed

+14
-26
lines changed

app-rails/app/controllers/users/registrations_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ def create
1818
end
1919

2020
begin
21-
auth_service.register(@form.email, @form.password, @form.role)
21+
auth_service.register(@form.email, @form.password)
2222
rescue Auth::Errors::BaseAuthError => e
2323
flash.now[:errors] = [ e.message ]
2424
return render :new, status: :unprocessable_entity
@@ -72,7 +72,7 @@ def auth_service
7272
end
7373

7474
def registration_params
75-
params.require(:users_registration_form).permit(:email, :password, :password_confirmation, :role, :spam_trap)
75+
params.require(:users_registration_form).permit(:email, :password, :password_confirmation, :spam_trap)
7676
end
7777

7878
def verify_account_params

app-rails/app/forms/users/registration_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class Users::RegistrationForm
44
include ActiveModel::Model
55

6-
attr_accessor :email, :password, :password_confirmation, :role, :spam_trap
6+
attr_accessor :email, :password, :password_confirmation, :spam_trap
77

88
validates :email, :password, presence: true
99
validates :email, format: { with: URI::MailTo::EMAIL_REGEXP }, if: -> { email.present? }

app-rails/app/models/user_role.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.

app-rails/app/services/auth_service.rb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ def respond_to_auth_challenge(code, challenge = {})
3434
handle_auth_result(response, challenge[:email])
3535
end
3636

37-
def register(email, password, role)
37+
def register(email, password)
3838
# @TODO: Handle errors from the auth service, like when the email is already taken
3939
# See https://github.com/navapbc/template-application-rails/issues/15
4040
account = @auth_adapter.create_account(email, password)
4141

42-
create_db_user(account[:uid], email, account[:provider], role)
42+
create_db_user(account[:uid], email, account[:provider])
4343
end
4444

4545
# Verify the code sent to the user as part of their initial sign up process.
@@ -72,15 +72,14 @@ def disable_software_token(user)
7272

7373
private
7474

75-
def create_db_user(uid, email, provider, role = "applicant")
76-
Rails.logger.info "Creating User uid: #{uid}, and UserRole: #{role}"
75+
def create_db_user(uid, email, provider)
76+
Rails.logger.info "Creating User uid: #{uid}"
7777

7878
user = User.create!(
7979
uid: uid,
8080
email: email,
8181
provider: provider,
8282
)
83-
user_role = UserRole.create!(user: user, role: role)
8483
user
8584
end
8685

app-rails/app/views/users/registrations/new.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<% content_for :title, t(".title") %>
22
<% icon = "local_library" %>
3-
<% icon_color = @form.role == "applicant" ? "violet" : "mint" %>
3+
<% icon_color = "violet" %>
44

55
<div class="bg-white padding-top-3 padding-bottom-5 padding-x-5 border border-base-lighter">
66
<div class="text-center margin-bottom-2 padding-bottom-2 border-bottom border-base-lighter">

app-rails/spec/controllers/users/registrations_controller_spec.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
users_registration_form: {
2626
email: email,
2727
password: "password",
28-
role: "employer"
2928
},
3029
locale: "en"
3130
}
@@ -40,7 +39,6 @@
4039
users_registration_form: {
4140
email: "invalid",
4241
password: "password",
43-
role: "employer"
4442
},
4543
locale: "en"
4644
}
@@ -53,7 +51,6 @@
5351
users_registration_form: {
5452
email: "UsernameExists@example.com",
5553
password: "password",
56-
role: "employer"
5754
},
5855
locale: "en"
5956
}
@@ -68,7 +65,7 @@
6865
users_registration_form: {
6966
email: email,
7067
password: "password",
71-
role: "employer",
68+
7269
spam_trap: "I am a bot"
7370
},
7471
locale: "en"

app-rails/spec/controllers/users/sessions_controller_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
expect(response.body).to have_selector(".usa-alert--error")
3939
end
4040

41-
it "signs in a applicant and redirects to their account page (for now)" do
41+
it "signs in a user and redirects to their account page (for now)" do
4242
create(:user, uid: uid)
4343

4444
post :create, params: {
@@ -141,7 +141,7 @@
141141
expect(response.body).to have_selector(".usa-alert--error")
142142
end
143143

144-
it "signs in a applicant and redirects to their account page (for now)" do
144+
it "signs in a user and redirects to their account page (for now)" do
145145
create(:user, uid: uid)
146146
session[:challenge_session] = "session"
147147
session[:challenge_email] = "test@example.com"

app-rails/spec/forms/users/registration_form_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
valid_password = "password1234"
44

55
RSpec.describe Users::RegistrationForm do
6-
let (:form) { Users::RegistrationForm.new(role: "applicant") }
6+
let (:form) { Users::RegistrationForm.new() }
77

88
it "passes validation with valid email and password" do
99
form.email = "test@example.com"

app-rails/spec/services/auth_service_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
let(:mock_auth_adapter) { Auth::MockAdapter.new(uid_generator: -> { mock_uid }) }
66

77
describe "#register" do
8-
it "creates a new user with the given role" do
8+
it "creates a new user" do
99
auth_service = AuthService.new(mock_auth_adapter)
1010

11-
auth_service.register("test@example.com", "password", "employer")
11+
auth_service.register("test@example.com", "password")
1212

1313
user = User.find_by(uid: mock_uid)
1414
expect(user).to be_present

0 commit comments

Comments
 (0)