From eddf4c0f6cb6125a30cbc2528a468d2c3d5a48e0 Mon Sep 17 00:00:00 2001 From: Peter Lauck Date: Tue, 13 Feb 2018 02:21:42 -0500 Subject: Strip whitespace from username/login value for user lookup As per the discussion with @psimyn, this change does not affect the frontend, so user input will not be validated on the signin screen. Instead, the value sent to the backend has leading and trailing whitespace stripped before looking up the user with find_by. Closes #42637 --- app/models/user.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app') diff --git a/app/models/user.rb b/app/models/user.rb index 4097fe2b5dc..5e84d2da805 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -249,7 +249,7 @@ class User < ActiveRecord::Base def find_for_database_authentication(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) - where(conditions).find_by("lower(username) = :value OR lower(email) = :value", value: login.downcase) + where(conditions).find_by("lower(username) = :value OR lower(email) = :value", value: login.downcase.strip) else find_by(conditions) end -- cgit v1.2.1