diff --git a/README.md b/README.md index 0b4c2dd..42f38f9 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,4 @@ [![travis status](https://api.travis-ci.org/atomaka/link-share.png)](https://travis-ci.org/atomaka/link-share) +[![codebeat badge](https://codebeat.co/badges/7a333669-bde0-48aa-ad92-483c4c0c4275)](https://codebeat.co/projects/github-com-atomaka-link-share) # link-share diff --git a/helpers/application_helper.rb b/helpers/application_helper.rb index 678ba9d..779e390 100644 --- a/helpers/application_helper.rb +++ b/helpers/application_helper.rb @@ -7,14 +7,17 @@ helpers do def authorized? @auth ||= Rack::Auth::Basic::Request.new(request.env) - return unless @auth.provided? and @auth.basic? + return unless @auth.provided? && @auth.basic? - username, password = @auth.credentials - - user_exists?(username) && settings.users[username] == password + authenticate?(@auth.credentials) end - def user_exists?(username) - settings.users.keys.include?(username) + def authenticate?(credentials) + username, password = credentials + users.keys.include?(username) && users[username] == password + end + + def users + settings.users end end