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
Boxiang Sun
gitlab-ce
Commits
a73df4f7
Commit
a73df4f7
authored
Apr 07, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow oauth signup without email
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
4e002a71
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
29 additions
and
4 deletions
+29
-4
app/controllers/application_controller.rb
app/controllers/application_controller.rb
+7
-0
app/controllers/profiles/emails_controller.rb
app/controllers/profiles/emails_controller.rb
+1
-1
app/controllers/profiles_controller.rb
app/controllers/profiles_controller.rb
+1
-0
app/models/user.rb
app/models/user.rb
+8
-0
app/views/profiles/show.html.haml
app/views/profiles/show.html.haml
+4
-1
lib/gitlab/oauth/user.rb
lib/gitlab/oauth/user.rb
+8
-2
No files found.
app/controllers/application_controller.rb
View file @
a73df4f7
...
@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base
...
@@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base
before_filter
:default_headers
before_filter
:default_headers
before_filter
:add_gon_variables
before_filter
:add_gon_variables
before_filter
:configure_permitted_parameters
,
if: :devise_controller?
before_filter
:configure_permitted_parameters
,
if: :devise_controller?
before_filter
:require_email
protect_from_forgery
protect_from_forgery
...
@@ -234,4 +235,10 @@ class ApplicationController < ActionController::Base
...
@@ -234,4 +235,10 @@ class ApplicationController < ActionController::Base
def
hexdigest
(
string
)
def
hexdigest
(
string
)
Digest
::
SHA1
.
hexdigest
string
Digest
::
SHA1
.
hexdigest
string
end
end
def
require_email
if
current_user
&&
current_user
.
temp_oauth_email?
redirect_to
profile_path
,
notice:
'Please complete your profile with email address'
and
return
end
end
end
end
app/controllers/profiles/emails_controller.rb
View file @
a73df4f7
app/controllers/profiles_controller.rb
View file @
a73df4f7
...
@@ -3,6 +3,7 @@ class ProfilesController < ApplicationController
...
@@ -3,6 +3,7 @@ class ProfilesController < ApplicationController
before_filter
:user
before_filter
:user
before_filter
:authorize_change_username!
,
only: :update_username
before_filter
:authorize_change_username!
,
only: :update_username
skip_before_filter
:require_email
,
only:
[
:show
,
:update
]
layout
'profile'
layout
'profile'
...
...
app/models/user.rb
View file @
a73df4f7
...
@@ -462,4 +462,12 @@ class User < ActiveRecord::Base
...
@@ -462,4 +462,12 @@ class User < ActiveRecord::Base
def
all_ssh_keys
def
all_ssh_keys
keys
.
map
(
&
:key
)
keys
.
map
(
&
:key
)
end
end
def
temp_oauth_email?
email
=~
/\Atemp-email-for-oauth/
end
def
generate_tmp_oauth_email
self
.
email
=
"temp-email-for-oauth-
#{
username
}
"
end
end
end
app/views/profiles/show.html.haml
View file @
a73df4f7
...
@@ -29,6 +29,9 @@
...
@@ -29,6 +29,9 @@
=
f
.
text_field
:email
,
class:
"form-control"
,
required:
true
,
readonly:
true
=
f
.
text_field
:email
,
class:
"form-control"
,
required:
true
,
readonly:
true
%span
.help-block.light
%span
.help-block.light
Email is read-only for LDAP user
Email is read-only for LDAP user
-
else
-
if
@user
.
temp_oauth_email?
=
f
.
text_field
:email
,
class:
"form-control"
,
required:
true
,
value:
nil
-
else
-
else
=
f
.
text_field
:email
,
class:
"form-control"
,
required:
true
=
f
.
text_field
:email
,
class:
"form-control"
,
required:
true
-
if
@user
.
unconfirmed_email
.
present?
-
if
@user
.
unconfirmed_email
.
present?
...
...
lib/gitlab/oauth/user.rb
View file @
a73df4f7
...
@@ -29,7 +29,13 @@ module Gitlab
...
@@ -29,7 +29,13 @@ module Gitlab
user
=
model
.
build_user
(
opts
,
as: :admin
)
user
=
model
.
build_user
(
opts
,
as: :admin
)
user
.
skip_confirmation!
user
.
skip_confirmation!
user
.
save!
if
user
.
email
.
blank?
user
.
generate_tmp_oauth_email
end
user
.
save!
(
validate:
false
)
log
.
info
"(OAuth) Creating user
#{
email
}
from login with extern_uid =>
#{
uid
}
"
log
.
info
"(OAuth) Creating user
#{
email
}
from login with extern_uid =>
#{
uid
}
"
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap?
if
Gitlab
.
config
.
omniauth
[
'block_auto_created_users'
]
&&
!
ldap?
...
@@ -58,7 +64,7 @@ module Gitlab
...
@@ -58,7 +64,7 @@ module Gitlab
end
end
def
username
def
username
email
.
match
(
/^[^@]*/
)[
0
]
auth
.
info
.
nickname
.
to_s
.
force_encoding
(
"utf-8"
)
end
end
def
provider
def
provider
...
...
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