mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-27 04:51:14 +00:00
Added ability to login with a username that is case insensitive
Added some missing translations Small CSS tweaks
This commit is contained in:
parent
2021af051c
commit
1e6d3efc14
12 changed files with 54 additions and 12 deletions
|
@ -18,8 +18,10 @@ div
|
||||||
> h1
|
> h1
|
||||||
@include shaded-top
|
@include shaded-top
|
||||||
box-sizing: border-box
|
box-sizing: border-box
|
||||||
|
padding: 8px
|
||||||
margin: 0
|
margin: 0
|
||||||
width: 100%
|
width: 100%
|
||||||
|
height: 35px
|
||||||
font-size: 140%
|
font-size: 140%
|
||||||
h1 a
|
h1 a
|
||||||
color: #ffffff
|
color: #ffffff
|
||||||
|
|
|
@ -13,5 +13,6 @@ div
|
||||||
&.flashMsg
|
&.flashMsg
|
||||||
background-color: green
|
background-color: green
|
||||||
color: white
|
color: white
|
||||||
|
margin-bottom: 20px
|
||||||
&.flashError
|
&.flashError
|
||||||
background-color: red
|
background-color: red
|
|
@ -80,7 +80,7 @@ class UsersController < ApplicationController
|
||||||
def login
|
def login
|
||||||
return unless request.post?
|
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
|
raise Error, t(:accounts_locked) if u.banned? Ban::TYPE_SITE
|
||||||
|
|
||||||
flash[:notice] = t(:login_successful)
|
flash[:notice] = t(:login_successful)
|
||||||
|
|
|
@ -258,8 +258,8 @@ class User < ActiveRecord::Base
|
||||||
cuser and cuser.admin?
|
cuser and cuser.admin?
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.authenticate username, password
|
def self.authenticate(username, password)
|
||||||
User.first :conditions => {:username => username, :password => Digest::MD5.hexdigest(password)}
|
where("LOWER(username) = LOWER(?)", username).where(:password => Digest::MD5.hexdigest(password)).first
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.get id
|
def self.get id
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<div id="indexBanner">
|
<div id="indexBanner">
|
||||||
<div id="indexLinks">
|
<div id="indexLinks">
|
||||||
<% if cuser %>
|
<% if cuser %>
|
||||||
<span>Logged in as: <%= namelink cuser %></span> |
|
<span><%= t('login_status') %>: <%= namelink(cuser) %></span> |
|
||||||
<% end %>
|
<% end %>
|
||||||
<% if cuser and cuser.admin? %>
|
<% if cuser and cuser.admin? %>
|
||||||
<%= link_to "/about/adminpanel", :style => "color: #CC0000" do %>
|
<%= link_to "/about/adminpanel", :style => "color: #CC0000" do %>
|
||||||
|
|
|
@ -39,7 +39,7 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="indexBox">
|
<div class="indexBox">
|
||||||
<div class="header">Shoutbox & Match search</div>
|
<div class="header"><%= t('widget.shoutbox') %></div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<%= render :partial => "widgets/shoutbox" %>
|
<%= render :partial => "widgets/shoutbox" %>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="header">Match Schedule</div>
|
<div class="header"><%= t('widget.schedule') %></div>
|
||||||
|
|
||||||
<div class="widget-content-wrapper">
|
<div class="widget-content-wrapper">
|
||||||
<% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %>
|
<% upcoming_matches.group_by{ |e| e.start.month }.each do |month, events| %>
|
||||||
|
@ -13,4 +13,3 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="header">Highlights</div>
|
<div class="header"><%= t('widget.highlights') %></div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<div class="header">Latest Posts</div>
|
<div class="header"><%= t('widget.posts') %></div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h3>
|
<h3>
|
||||||
|
@ -7,7 +7,7 @@
|
||||||
<ol>
|
<ol>
|
||||||
<% Topic.basic.recent.latest_page(1).each do |topic| %>
|
<% Topic.basic.recent.latest_page(1).each do |topic| %>
|
||||||
<li>
|
<li>
|
||||||
<%= link_to shorten(topic, 30), lastpost(topic) %>
|
<%= link_to shorten(topic, 35), lastpost(topic) %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
@ -19,7 +19,7 @@
|
||||||
<% Comment.recent.filtered.each do |comment| %>
|
<% Comment.recent.filtered.each do |comment| %>
|
||||||
<li>
|
<li>
|
||||||
<%= namelink comment.commentable, 15 %>
|
<%= namelink comment.commentable, 15 %>
|
||||||
by <%= namelink comment.user, 8 %>
|
by <%= namelink comment.user, 15 %>
|
||||||
</li>
|
</li>
|
||||||
<% end %>
|
<% end %>
|
||||||
</ol>
|
</ol>
|
||||||
|
|
|
@ -74,6 +74,7 @@ en:
|
||||||
login_successful: "Login Successful"
|
login_successful: "Login Successful"
|
||||||
login_unsuccessful: "Login Unsuccessful"
|
login_unsuccessful: "Login Unsuccessful"
|
||||||
login_out: "Logged out."
|
login_out: "Logged out."
|
||||||
|
login_status: "Logged in as"
|
||||||
passwords_sent: "Password has been sent."
|
passwords_sent: "Password has been sent."
|
||||||
incorrect_information: "Incorrect Information."
|
incorrect_information: "Incorrect Information."
|
||||||
weeks_create: "Week was successfully created."
|
weeks_create: "Week was successfully created."
|
||||||
|
@ -81,6 +82,11 @@ en:
|
||||||
votes_success: "Voted successfully."
|
votes_success: "Voted successfully."
|
||||||
error: "error"
|
error: "error"
|
||||||
prohibited: "prohibited"
|
prohibited: "prohibited"
|
||||||
|
widget:
|
||||||
|
schedule: "Match Schedule"
|
||||||
|
shoutbox: "Shoutbox & Match search"
|
||||||
|
highlights: "Highlights"
|
||||||
|
posts: "Latest Posts"
|
||||||
profile:
|
profile:
|
||||||
locals: "Locals"
|
locals: "Locals"
|
||||||
sessions:
|
sessions:
|
||||||
|
|
34
spec/features/users/case_insensitive_login_spec.rb
Normal file
34
spec/features/users/case_insensitive_login_spec.rb
Normal file
|
@ -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
|
Loading…
Reference in a new issue