summaryrefslogtreecommitdiff
path: root/lib/gitlab/o_auth
diff options
context:
space:
mode:
authorOnur Küçük <onur@delipenguen.net>2015-05-03 00:43:46 +0300
committerOnur Küçük <onur@delipenguen.net>2015-05-03 00:43:46 +0300
commit0ae574007d2118fc6e291591121ceca2da6fc22e (patch)
treee9afa10b2f734a2f576e0174c0726e9b615bcf9b /lib/gitlab/o_auth
parent76f7bdccc09fe1290cee330480c1a2640e3b20d5 (diff)
downloadgitlab-ce-0ae574007d2118fc6e291591121ceca2da6fc22e.tar.gz
add common method to force utf8 and force oauth properties to be utf8
Diffstat (limited to 'lib/gitlab/o_auth')
-rw-r--r--lib/gitlab/o_auth/auth_hash.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/gitlab/o_auth/auth_hash.rb b/lib/gitlab/o_auth/auth_hash.rb
index ce52beec78e..0f16c925900 100644
--- a/lib/gitlab/o_auth/auth_hash.rb
+++ b/lib/gitlab/o_auth/auth_hash.rb
@@ -9,11 +9,11 @@ module Gitlab
end
def uid
- auth_hash.uid.to_s
+ Gitlab::Utils.force_utf8(auth_hash.uid.to_s)
end
def provider
- auth_hash.provider
+ Gitlab::Utils.force_utf8(auth_hash.provider.to_s)
end
def info
@@ -21,23 +21,28 @@ module Gitlab
end
def name
- (info.try(:name) || full_name).to_s.force_encoding('utf-8')
+ Gitlab::Utils.force_utf8((info.try(:name) || full_name).to_s)
end
def full_name
- "#{info.first_name} #{info.last_name}"
+ Gitlab::Utils.force_utf8("#{info.first_name} #{info.last_name}")
end
def username
- (info.try(:nickname) || generate_username).to_s.force_encoding('utf-8')
+ Gitlab::Utils.force_utf8(
+ (info.try(:nickname) || generate_username).to_s
+ )
end
def email
- (info.try(:email) || generate_temporarily_email).downcase
+ Gitlab::Utils.force_utf8(
+ (info.try(:email) || generate_temporarily_email).downcase
+ )
end
def password
- @password ||= Devise.friendly_token[0, 8].downcase
+ devise_friendly_token = Devise.friendly_token[0, 8].downcase
+ @password ||= Gitlab::Utils.force_utf8(devise_friendly_token)
end
# Get the first part of the email address (before @)