> On 2017-Aug-7, at 03:06 , Fatos Morina <fatosi.mor...@gmail.com> wrote: > > 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[0]
Why not simply do: username, password = ActionController::HttpAuthentication::Basic::user_name_and_password (there's no need for a new method and there's already array assignment so no need to explicitly index the result) -Rob > > 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. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Core" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-core+unsubscr...@googlegroups.com > <mailto:rubyonrails-core+unsubscr...@googlegroups.com>. > To post to this group, send email to rubyonrails-core@googlegroups.com > <mailto:rubyonrails-core@googlegroups.com>. > Visit this group at https://groups.google.com/group/rubyonrails-core > <https://groups.google.com/group/rubyonrails-core>. > For more options, visit https://groups.google.com/d/optout > <https://groups.google.com/d/optout>. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.