Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Jérome Perrin
gitlab-ce
Commits
18f88a1b
Commit
18f88a1b
authored
Sep 04, 2014
by
Jan-Willem van der Meer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new Gitlab::Oauth::AuthHash class
parent
5b86dab0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
0 deletions
+54
-0
lib/gitlab/oauth/auth_hash.rb
lib/gitlab/oauth/auth_hash.rb
+54
-0
No files found.
lib/gitlab/oauth/auth_hash.rb
0 → 100644
View file @
18f88a1b
# Class to parse and transform the info provided by omniauth
#
module
Gitlab
module
OAuth
class
AuthHash
attr_reader
:auth_hash
def
initialize
(
auth_hash
)
@auth_hash
=
auth_hash
end
def
uid
auth_hash
.
uid
.
to_s
end
def
provider
auth_hash
.
provider
end
def
info
auth_hash
.
info
end
def
name
(
info
.
name
||
full_name
).
to_s
.
force_encoding
(
'utf-8'
)
end
def
full_name
"
#{
info
.
first_name
}
#{
info
.
last_name
}
"
end
def
username
(
info
.
try
(
:nickname
)
||
generate_username
).
to_s
.
force_encoding
(
'utf-8'
)
end
def
email
(
info
.
try
(
:email
)
||
generate_temporarily_email
).
downcase
end
def
password
@password
||=
Devise
.
friendly_token
[
0
,
8
].
downcase
end
# Get the first part of the email address (before @)
# In addtion in removes illegal characters
def
generate_username
email
.
match
(
/^[^@]*/
)[
0
].
parameterize
end
def
generate_temporarily_email
"temp-email-for-oauth-
#{
username
}
@gitlab.localhost"
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment