Below is a standard registration/sign_in form generated by Devise. I’ve added custom fields first_name, last_name, and mobile_number to this form and Devise User model.
Scenario: Initially a new user is able to register/create an account by entering first_name, last_name and mobile_number.
I would like the following: To authenticate a user based on a custom auto generated email address. For instance first_name+last_name@foobar.com plus mobile_number as the password which was entered by the user when he/she first registered.
I’m getting a 401 unauthorized, can this be done or will strong_params complain? I’m scratching my head at the moment…
.container
%h2 Sign up
= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
= f.error_notification
.form-inputs
= f.input :email, required: true, autofocus: true, class: "form-control input-sm"
= f.input :password, required: true, hint: ("#{@minimum_password_length} characters minimum" if @minimum_password_length)
= f.input :password_confirmation, required: true
.form-actions
= f.button :submit, "Sign up"
= render "devise/shared/links"
I created a simple helper method to take the inputs fields first_name + last_name to generate the email address.
def account_email(first_name, last_name)
"#{first_name.downcase}#{last_name.downcase}@foobar.com"
end