Hi fellow coders,
I have recently been implementing an API and used Basic Auth as the authentication method. Besides doing the authentication part, I need to extract the email from the request header for other usages.
Currently, we can extract username the following way:
username = ActionController::HttpAuthentication::Basic::user_name_and_password
But I wanted to propose to add two new methods: One for getting the username, and the other one for taking the password, so that we do not need to use array indexes to get each one. Then we can refactor ActionController::HttpAuthentication::Basic::user_name_and_password and prepare the response from these new methods.
This sounds as something really simple, that may not be that important, but I believe it greatly fits with the central principle of Ruby, as Matz says:
“Ruby is designed to make programmers happy.”
If this does resonate with you, I would be more than happy and grateful to implement it.
Thank you very much.