Commit 03cc55dba6883ba9e5fa9301464523a25b77f164
1 parent
01bb42ae
Exists in
master
and in
4 other branches
Force utf-8 encoding for ldap omniauth_info.name
Showing
1 changed file
with
7 additions
and
7 deletions
Show diff stats
app/models/user.rb
| ... | ... | @@ -13,7 +13,7 @@ class User < ActiveRecord::Base |
| 13 | 13 | has_many :my_own_projects, :class_name => "Project", :foreign_key => :owner_id |
| 14 | 14 | has_many :keys, :dependent => :destroy |
| 15 | 15 | |
| 16 | - has_many :recent_events, | |
| 16 | + has_many :recent_events, | |
| 17 | 17 | :class_name => "Event", |
| 18 | 18 | :foreign_key => :author_id, |
| 19 | 19 | :order => "id DESC" |
| ... | ... | @@ -43,7 +43,7 @@ class User < ActiveRecord::Base |
| 43 | 43 | validates :projects_limit, |
| 44 | 44 | :presence => true, |
| 45 | 45 | :numericality => {:greater_than_or_equal_to => 0} |
| 46 | - | |
| 46 | + | |
| 47 | 47 | validates :bio, :length => { :within => 0..255 } |
| 48 | 48 | |
| 49 | 49 | before_create :ensure_authentication_token |
| ... | ... | @@ -93,14 +93,14 @@ class User < ActiveRecord::Base |
| 93 | 93 | (0...8).map{ ('a'..'z').to_a[rand(26)] }.join |
| 94 | 94 | end |
| 95 | 95 | |
| 96 | - def first_name | |
| 96 | + def first_name | |
| 97 | 97 | name.split(" ").first unless name.blank? |
| 98 | 98 | end |
| 99 | 99 | |
| 100 | 100 | def self.find_for_ldap_auth(omniauth_info) |
| 101 | - name = omniauth_info.name | |
| 101 | + name = omniauth_info.name.force_encoding("utf-8") | |
| 102 | 102 | email = omniauth_info.email.downcase |
| 103 | - | |
| 103 | + | |
| 104 | 104 | if @user = User.find_by_email(email) |
| 105 | 105 | @user |
| 106 | 106 | else |
| ... | ... | @@ -123,8 +123,8 @@ class User < ActiveRecord::Base |
| 123 | 123 | |
| 124 | 124 | # Remove user from all projects and |
| 125 | 125 | # set blocked attribute to true |
| 126 | - def block | |
| 127 | - users_projects.all.each do |membership| | |
| 126 | + def block | |
| 127 | + users_projects.all.each do |membership| | |
| 128 | 128 | return false unless membership.destroy |
| 129 | 129 | end |
| 130 | 130 | ... | ... |