diff options
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/application_controller.rb | 7 | ||||
-rw-r--r-- | app/controllers/profiles/emails_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/profiles_controller.rb | 1 | ||||
-rw-r--r-- | app/models/user.rb | 8 | ||||
-rw-r--r-- | app/views/devise/sessions/_oauth_providers.html.haml | 2 | ||||
-rw-r--r-- | app/views/profiles/show.html.haml | 8 | ||||
-rw-r--r-- | doc/integration/README.md | 2 | ||||
-rw-r--r-- | doc/integration/external-issue-tracker.md | 4 | ||||
-rw-r--r-- | doc/integration/github_app.png | bin | 0 -> 75607 bytes | |||
-rw-r--r-- | doc/integration/oauth.md (renamed from doc/integration/twitter_oauth.md) | 2 | ||||
-rw-r--r-- | lib/gitlab/oauth/user.rb | 13 | ||||
-rw-r--r-- | spec/lib/oauth_spec.rb | 1 |
13 files changed, 41 insertions, 10 deletions
diff --git a/CHANGELOG b/CHANGELOG index a6f2b36d31c..f0a72710a92 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,6 +10,7 @@ v 6.8.0 - Protected branch does not allow force push - Fix popen bug in `rake gitlab:satellites:create` - Disable connection reaping for MySQL + - Allow oauth signup without email for twitter and github v 6.7.3 - Fix the merge notification email not being sent (Pierre de La Morinerie) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 5f8b2da06f8..a3f39c23e08 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -11,6 +11,7 @@ class ApplicationController < ActionController::Base before_filter :default_headers before_filter :add_gon_variables before_filter :configure_permitted_parameters, if: :devise_controller? + before_filter :require_email, unless: :devise_controller? protect_from_forgery @@ -234,4 +235,10 @@ class ApplicationController < ActionController::Base def hexdigest(string) Digest::SHA1.hexdigest string 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 diff --git a/app/controllers/profiles/emails_controller.rb b/app/controllers/profiles/emails_controller.rb index 9996b67a8a4..40c352dab0c 100644 --- a/app/controllers/profiles/emails_controller.rb +++ b/app/controllers/profiles/emails_controller.rb @@ -8,7 +8,7 @@ class Profiles::EmailsController < ApplicationController def create @email = current_user.emails.new(params[:email]) - + flash[:alert] = @email.errors.full_messages.first unless @email.save redirect_to profile_emails_url diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index 9234cd1708f..9c9a129b26b 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -3,6 +3,7 @@ class ProfilesController < ApplicationController before_filter :user before_filter :authorize_change_username!, only: :update_username + skip_before_filter :require_email, only: [:show, :update] layout 'profile' diff --git a/app/models/user.rb b/app/models/user.rb index 25c10a6faa0..58d90f03b34 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -462,4 +462,12 @@ class User < ActiveRecord::Base def all_ssh_keys keys.map(&:key) end + + def temp_oauth_email? + email =~ /\Atemp-email-for-oauth/ + end + + def generate_tmp_oauth_email + self.email = "temp-email-for-oauth-#{username}@gitlab.localhost" + end end diff --git a/app/views/devise/sessions/_oauth_providers.html.haml b/app/views/devise/sessions/_oauth_providers.html.haml index 2b1cb9c694f..f4556eea4a2 100644 --- a/app/views/devise/sessions/_oauth_providers.html.haml +++ b/app/views/devise/sessions/_oauth_providers.html.haml @@ -9,5 +9,3 @@ = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) - else = link_to provider.to_s.titleize, omniauth_authorize_path(resource_name, provider), class: "btn" - %br - %small * Make sure your email address is public diff --git a/app/views/profiles/show.html.haml b/app/views/profiles/show.html.haml index 523a07db400..69598e799e5 100644 --- a/app/views/profiles/show.html.haml +++ b/app/views/profiles/show.html.haml @@ -30,11 +30,15 @@ %span.help-block.light Email is read-only for LDAP user - else - = f.text_field :email, class: "form-control", required: true + - if @user.temp_oauth_email? + = f.text_field :email, class: "form-control", required: true, value: nil + - else + = f.text_field :email, class: "form-control", required: true - if @user.unconfirmed_email.present? %span.help-block - We sent confirmation email to + Please click the link in the confirmation email before continuing, it was send to %strong #{@user.unconfirmed_email} + - else %span.help-block We also use email for avatar detection if no avatar is uploaded. .form-group diff --git a/doc/integration/README.md b/doc/integration/README.md index 6878f875ad7..fac43c63e9a 100644 --- a/doc/integration/README.md +++ b/doc/integration/README.md @@ -1,3 +1,3 @@ + [External issue tracker](external-issue-tracker.md) + [LDAP](ldap.md) -+ [Twitter](twitter.md) ++ [oAuth](oauth.md) Login with Twitter, GitHub, etc.
\ No newline at end of file diff --git a/doc/integration/external-issue-tracker.md b/doc/integration/external-issue-tracker.md index 6b34826da52..7d8312075ac 100644 --- a/doc/integration/external-issue-tracker.md +++ b/doc/integration/external-issue-tracker.md @@ -4,6 +4,6 @@ GitLab has a great issue tracker but you can also use an external issue tracker - clicking 'New issue' on the project dashboard creates a new JIRA issue; - To reference JIRA issue PROJECT-1234 in comments, use syntax #PROJECT-1234. Commit messages get turned into HTML links to the corresponding JIRA issue. -![jira screenshot](jira-intergration-points.png) +![jira screenshot](jira-integration-points.png) -You can configure the integration in the gitlab.yml configuration file. +You can configure the integration in the gitlab.yml configuration file.
\ No newline at end of file diff --git a/doc/integration/github_app.png b/doc/integration/github_app.png Binary files differnew file mode 100644 index 00000000000..c0873b2e20d --- /dev/null +++ b/doc/integration/github_app.png diff --git a/doc/integration/twitter_oauth.md b/doc/integration/oauth.md index fd2b72a8778..bdbf99b4174 100644 --- a/doc/integration/twitter_oauth.md +++ b/doc/integration/oauth.md @@ -1,4 +1,4 @@ -You can use Twitter to log into GitLab. +You can use other services to log into GitLab via oAuth. Please configure this in gitlab.yml diff --git a/lib/gitlab/oauth/user.rb b/lib/gitlab/oauth/user.rb index 529753c4019..1bac93378ef 100644 --- a/lib/gitlab/oauth/user.rb +++ b/lib/gitlab/oauth/user.rb @@ -29,6 +29,17 @@ module Gitlab user = model.build_user(opts, as: :admin) user.skip_confirmation! + + # Services like twitter and github does not return email via oauth + # In this case we generate temporary email and force user to fill it later + if user.email.blank? + user.generate_tmp_oauth_email + else + # Google oauth returns email but dont return nickname + # So we use part of email as username for new user + user.username = email.match(/^[^@]*/)[0] + end + user.save! log.info "(OAuth) Creating user #{email} from login with extern_uid => #{uid}" @@ -58,7 +69,7 @@ module Gitlab end def username - email.match(/^[^@]*/)[0] + auth.info.nickname.to_s.force_encoding("utf-8") end def provider diff --git a/spec/lib/oauth_spec.rb b/spec/lib/oauth_spec.rb index 3dfe95a8e38..2f15b5e0349 100644 --- a/spec/lib/oauth_spec.rb +++ b/spec/lib/oauth_spec.rb @@ -8,6 +8,7 @@ describe Gitlab::OAuth::User do @info = double( uid: '12djsak321', + nickname: 'john', name: 'John', email: 'john@mail.com' ) |