Hello All,
Would someone help provide some guidance as to how I can configure my rails API project to register a new user with a username + email but only require the username for login? I'm planning on disabling the API / POST route to user/tokens/sign_up and create these accounts using the rails console. However, for support purposes, I want to be able to associate an email to each account such that I'm aware of who ones the "service account" username if any user management ever needed to take place.
I don't want to require email on sign in, I want them to only use their username and email. I've been playing around with it for the past couple of days, I've updated the devise config in config/initializers/devise.rb config.authentication_keys = [:username].
I've also added this to my application_controller:
before_action :configure_permitted_parameters, if: :devise_controller?
protected
def configure_permitted_parameters
devise_parameter_sanitizer.permit(:sign_up, keys: [:username])
devise_parameter_sanitizer.permit(:sign_in, keys: [:username])
end
In addition to added this to my app/models/user.rb
def email_required?
false
end
def will_save_change_to_email?
false
end
However, if I only register with the username, the email is blank "", I can't register another user without crashing the app with 500 error. I've been able to find a way to register accounts with a unique username and email but that also requires both the username and email when the user logs in. I would like multiple user accounts /usernames to be linked to the same email if a user has multiple service accounts.
Sorry for the brain dump but I hope it helps in providing context to better assist me with my support request.
Kind regards,
Truman
Hello All,
Would someone help provide some guidance as to how I can configure my rails API project to register a new user with a username + email but only require the username for login? I'm planning on disabling the API / POST route to user/tokens/sign_up and create these accounts using the rails console. However, for support purposes, I want to be able to associate an email to each account such that I'm aware of who ones the "service account" username if any user management ever needed to take place.
I don't want to require email on sign in, I want them to only use their username and email. I've been playing around with it for the past couple of days, I've updated the devise config in config/initializers/devise.rb config.authentication_keys = [:username].
I've also added this to my application_controller:
In addition to added this to my app/models/user.rb
However, if I only register with the username, the email is blank "", I can't register another user without crashing the app with 500 error. I've been able to find a way to register accounts with a unique username and email but that also requires both the username and email when the user logs in. I would like multiple user accounts /usernames to be linked to the same email if a user has multiple service accounts.
Sorry for the brain dump but I hope it helps in providing context to better assist me with my support request.
Kind regards,
Truman