Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

Allow logins to receive umlauts and other letter class chars

Oliver Güntherc1d5c23b1b4c
diff --git a/app/models/user.rb b/app/models/user.rb
index 51cce45acae..d7cd19c38e7 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -129,7 +129,7 @@ class User < Principal
validates :login, uniqueness: { if: Proc.new { |user| user.login.present? }, case_sensitive: false }
validates :mail, uniqueness: { allow_blank: true, case_sensitive: false }
# Login must contain letters, numbers, underscores only
- validates :login, format: { with: /\A[a-z0-9_\-@.+ ]*\z/i }
+ validates :login, format: { with: /\A[\p{L}0-9_\-@.+ ]*\z/i }
validates :login, length: { maximum: 256 }
validates :firstname, :lastname, length: { maximum: 256 }
diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb
index 9bbcb97d49f..121b8bdce4f 100644
--- a/spec/models/user_spec.rb
+++ b/spec/models/user_spec.rb
@@ -143,6 +143,18 @@ RSpec.describe User do
end
end
+ context 'with other letter char classes' do
+ let(:login) { "célîneüberölig" }
+
+ it 'is valid' do
+ expect(user).to be_valid
+ end
+
+ it 'may be stored in the database' do
+ expect(user.save).to be_truthy
+ end
+ end
+
context "with tabs" do
let(:login) { 'ab\tc' }
@@ -172,7 +184,7 @@ RSpec.describe User do
end
context "with combination thereof" do
- let(:login) { "the+boss-is@the_house." }
+ let(:login) { "the+boss-is-über@the_house." }
it "is valid" do
expect(user).to be_valid
diff --git a/spec/requests/auth/ldap_sso_spec.rb b/spec/requests/auth/ldap_sso_spec.rb
index 5d2858a013a..d1367a9fc0c 100644
--- a/spec/requests/auth/ldap_sso_spec.rb
+++ b/spec/requests/auth/ldap_sso_spec.rb
@@ -58,6 +58,23 @@ RSpec.describe "LDAP authentication",
expect(subject).to redirect_to "/?first_time_user=true"
end
+ context 'with a user that has umlauts in their name' do
+ let(:username) { 'bölle' }
+ let(:password) { 'bólle' }
+
+ it 'creates a user with umlauts on the fly' do
+ expect(User.find_by(login: 'bölle')).to be_nil
+
+ expect { subject }.to change(User.not_builtin.active, :count).by(1)
+
+ user = User.find_by(login: 'bölle')
+ expect(user).to be_present
+ expect(user).to be_active
+ expect(session[:user_id]).to eq user.id
+ expect(subject).to redirect_to '/?first_time_user=true'
+ end
+ end
+
context "when not all attributes present" do
let(:attr_mail) { nil }