diff --git a/app/assets/stylesheets/sass/articles.sass b/app/assets/stylesheets/sass/articles.sass index cf93039..7903a5f 100644 --- a/app/assets/stylesheets/sass/articles.sass +++ b/app/assets/stylesheets/sass/articles.sass @@ -18,8 +18,10 @@ div > h1 @include shaded-top box-sizing: border-box + padding: 8px margin: 0 width: 100% + height: 35px font-size: 140% h1 a color: #ffffff diff --git a/app/assets/stylesheets/sass/flash.sass b/app/assets/stylesheets/sass/flash.sass index 3e3acda..8497b4c 100644 --- a/app/assets/stylesheets/sass/flash.sass +++ b/app/assets/stylesheets/sass/flash.sass @@ -13,5 +13,6 @@ div &.flashMsg background-color: green color: white + margin-bottom: 20px &.flashError background-color: red \ No newline at end of file diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index dda9ad1..9879035 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -80,7 +80,7 @@ class UsersController < ApplicationController def login return unless request.post? - if u = User.authenticate(params[:login][:username], params[:login][:password]) + if u = User.authenticate(params[:login][:username].downcase, params[:login][:password]) raise Error, t(:accounts_locked) if u.banned? Ban::TYPE_SITE flash[:notice] = t(:login_successful) diff --git a/app/models/user.rb b/app/models/user.rb index 27b73ca..570ac8d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -258,8 +258,8 @@ class User < ActiveRecord::Base cuser and cuser.admin? end - def self.authenticate username, password - User.first :conditions => {:username => username, :password => Digest::MD5.hexdigest(password)} + def self.authenticate(username, password) + where("LOWER(username) = LOWER(?)", username).where(:password => Digest::MD5.hexdigest(password)).first end def self.get id diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 17d3f64..caa9d2b 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,7 +1,7 @@
-
Shoutbox & Match search
+
<%= t('widget.shoutbox') %>
<%= render :partial => "widgets/shoutbox" %> diff --git a/app/views/widgets/_calendar.html.erb b/app/views/widgets/_calendar.html.erb index 9589de8..ff31d58 100644 --- a/app/views/widgets/_calendar.html.erb +++ b/app/views/widgets/_calendar.html.erb @@ -1,4 +1,4 @@ -
Match Schedule
+
<%= t('widget.schedule') %>
<% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %> @@ -13,4 +13,3 @@ <% end %> <% end %>
- \ No newline at end of file diff --git a/app/views/widgets/_highlights.html.erb b/app/views/widgets/_highlights.html.erb index 407db11..235873d 100644 --- a/app/views/widgets/_highlights.html.erb +++ b/app/views/widgets/_highlights.html.erb @@ -1,4 +1,4 @@ -
Highlights
+
<%= t('widget.highlights') %>
diff --git a/app/views/widgets/_posts.html.erb b/app/views/widgets/_posts.html.erb index 0333fe1..9417ec9 100644 --- a/app/views/widgets/_posts.html.erb +++ b/app/views/widgets/_posts.html.erb @@ -1,4 +1,4 @@ -
Latest Posts
+
<%= t('widget.posts') %>

@@ -7,7 +7,7 @@
    <% Topic.basic.recent.latest_page(1).each do |topic| %>
  1. - <%= link_to shorten(topic, 30), lastpost(topic) %> + <%= link_to shorten(topic, 35), lastpost(topic) %>
  2. <% end %>
@@ -19,7 +19,7 @@ <% Comment.recent.filtered.each do |comment| %>
  • <%= namelink comment.commentable, 15 %> - by <%= namelink comment.user, 8 %> + by <%= namelink comment.user, 15 %>
  • <% end %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 25e2129..ff47b91 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -74,6 +74,7 @@ en: login_successful: "Login Successful" login_unsuccessful: "Login Unsuccessful" login_out: "Logged out." + login_status: "Logged in as" passwords_sent: "Password has been sent." incorrect_information: "Incorrect Information." weeks_create: "Week was successfully created." @@ -81,6 +82,11 @@ en: votes_success: "Voted successfully." error: "error" prohibited: "prohibited" + widget: + schedule: "Match Schedule" + shoutbox: "Shoutbox & Match search" + highlights: "Highlights" + posts: "Latest Posts" profile: locals: "Locals" sessions: diff --git a/spec/features/users/case_insensitive_login_spec.rb b/spec/features/users/case_insensitive_login_spec.rb new file mode 100644 index 0000000..7ebe378 --- /dev/null +++ b/spec/features/users/case_insensitive_login_spec.rb @@ -0,0 +1,34 @@ +require 'spec_helper' + +feature 'Case insensitive login' do + let(:username) { "CaSe_InSeNsItIvE" } + let(:password) { "passwordABC123" } + let!(:user) { create(:user, username: username, raw_password: password) } + + before do + visit root_path + end + + feature 'when a user with mixed-case username signs in' do + scenario 'with a matching case allows the user to sign in' do + fill_login_form(username) + click_button submit(:user, :login) + + expect(page).to have_content(I18n.t('login_successful')) + expect(page).to have_content("Logged in as: #{username}") + end + + scenario 'with a non-matching case allows the user to sign in' do + fill_login_form("CASE_INSENSITIVE") + click_button submit(:user, :login) + + expect(page).to have_content(I18n.t('login_successful')) + expect(page).to have_content("Logged in as: #{username}") + end + end + + def fill_login_form(username) + fill_in "login_username", with: username + fill_in "login_password", with: password + end +end diff --git a/spec/support/features/form_helpers.rb b/spec/support/features/form_helpers.rb index ba0338d..390b409 100644 --- a/spec/support/features/form_helpers.rb +++ b/spec/support/features/form_helpers.rb @@ -22,4 +22,4 @@ module Features I18n.t("helpers.submit.#{model}.#{action}") end end -end \ No newline at end of file +end