Commit fa4150d47d88b85d6027729844480a3e7c71d3cd
1 parent
486de8c3
Exists in
master
and in
4 other branches
Cleanup after omniauth
Showing
9 changed files
with
49 additions
and
47 deletions
Show diff stats
app/assets/stylesheets/auth_methods.scss
app/assets/stylesheets/gitlab_bootstrap/blocks.scss
app/assets/stylesheets/main.scss
app/controllers/omniauth_callbacks_controller.rb
| 1 | 1 | class OmniauthCallbacksController < Devise::OmniauthCallbacksController |
| 2 | + Gitlab.config.omniauth_providers.each do |provider| | |
| 3 | + define_method provider['name'] do | |
| 4 | + handle_omniauth | |
| 5 | + end | |
| 6 | + end | |
| 2 | 7 | |
| 3 | 8 | # Extend the standard message generation to accept our custom exception |
| 4 | 9 | def failure_message |
| ... | ... | @@ -19,12 +24,6 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController |
| 19 | 24 | sign_in_and_redirect @user |
| 20 | 25 | end |
| 21 | 26 | |
| 22 | - Settings.omniauth_providers.each do |provider| | |
| 23 | - define_method provider['name'] do | |
| 24 | - handle_omniauth | |
| 25 | - end | |
| 26 | - end | |
| 27 | - | |
| 28 | 27 | private |
| 29 | 28 | |
| 30 | 29 | def handle_omniauth | ... | ... |
app/helpers/application_helper.rb
| ... | ... | @@ -137,7 +137,8 @@ module ApplicationHelper |
| 137 | 137 | end |
| 138 | 138 | |
| 139 | 139 | def authbutton(provider, size = 64) |
| 140 | - image_tag("authbuttons/#{provider.to_s.split('_').first}_#{size}.png", | |
| 141 | - alt: "Sign in with #{provider.to_s.titleize}" ) | |
| 140 | + file_name = "#{provider.to_s.split('_').first}_#{size}.png" | |
| 141 | + image_tag("authbuttons/#{file_name}", | |
| 142 | + alt: "Sign in with #{provider.to_s.titleize}") | |
| 142 | 143 | end |
| 143 | 144 | end | ... | ... |
app/views/devise/sessions/new.html.haml
| ... | ... | @@ -15,7 +15,8 @@ |
| 15 | 15 | .right |
| 16 | 16 | = render :partial => "devise/shared/links" |
| 17 | 17 | - if devise_mapping.omniauthable? |
| 18 | - - resource_class.omniauth_providers.each do |provider| | |
| 19 | - %hr/ | |
| 20 | - = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), :class => "btn primary" | |
| 21 | - %br/ | |
| 18 | + %hr/ | |
| 19 | + %ul.unstyled | |
| 20 | + - resource_class.omniauth_providers.each do |provider| | |
| 21 | + %li | |
| 22 | + = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) | ... | ... |
app/views/profile/password.html.haml
| ... | ... | @@ -19,11 +19,11 @@ |
| 19 | 19 | = f.label :password_confirmation |
| 20 | 20 | .input= f.password_field :password_confirmation |
| 21 | 21 | |
| 22 | - - if Settings.omniauth.enabled | |
| 22 | + - if Gitlab.config.omniauth_enabled? | |
| 23 | 23 | .span5.right |
| 24 | - .auth_methods.alert.alert-info | |
| 24 | + .alert.alert-info | |
| 25 | 25 | %strong Tip: Use one of the following sites to login |
| 26 | - %ul | |
| 26 | + %ul.unstyled | |
| 27 | 27 | - User.omniauth_providers.each do |provider| |
| 28 | 28 | %li= link_to authbutton(provider), | |
| 29 | 29 | omniauth_authorize_path(User, provider) | | ... | ... |
app/views/profile/show.html.haml
| ... | ... | @@ -50,28 +50,34 @@ |
| 50 | 50 | %strong Tip: |
| 51 | 51 | You can change your avatar at gravatar.com |
| 52 | 52 | |
| 53 | - - if Settings.omniauth.enabled && @user.provider? | |
| 54 | - %h4 | |
| 55 | - Omniauth Providers: | |
| 56 | - = link_to "Change", profile_password_path, class: "btn small right" | |
| 57 | - You can login through #{@user.provider.titleize}! | |
| 58 | - = authbutton(@user.provider, 32) | |
| 53 | + - @user.provider = 'twitter' | |
| 54 | + - if Gitlab.config.omniauth_enabled? && @user.provider? | |
| 55 | + .ui-box | |
| 56 | + .ui-box-body | |
| 57 | + %h4 | |
| 58 | + Omniauth Providers: | |
| 59 | + = link_to "Change", profile_password_path, class: "btn small right" | |
| 60 | + You can login through #{@user.provider.titleize}! | |
| 61 | + = authbutton(@user.provider, 32) | |
| 59 | 62 | |
| 60 | - %h4 | |
| 61 | - Personal projects: | |
| 62 | - %small.right | |
| 63 | - %span= current_user.my_own_projects.count | |
| 64 | - of | |
| 65 | - %span= current_user.projects_limit | |
| 66 | - .progress | |
| 67 | - .bar{style: "width: #{current_user.projects_limit_percent}%;"} | |
| 63 | + .ui-box | |
| 64 | + .ui-box-body | |
| 65 | + %h4 | |
| 66 | + Personal projects: | |
| 67 | + %small.right | |
| 68 | + %span= current_user.my_own_projects.count | |
| 69 | + of | |
| 70 | + %span= current_user.projects_limit | |
| 71 | + .progress | |
| 72 | + .bar{style: "width: #{current_user.projects_limit_percent}%;"} | |
| 68 | 73 | |
| 69 | - %h4 | |
| 70 | - SSH public keys: | |
| 71 | - %small.right | |
| 72 | - %span= link_to current_user.keys.count, keys_path | |
| 74 | + .ui-box | |
| 75 | + .ui-box-body | |
| 76 | + %h4 | |
| 77 | + SSH public keys: | |
| 78 | + %strong.right= link_to current_user.keys.count, keys_path | |
| 73 | 79 | |
| 74 | - = link_to "Add Public Key", new_key_path, class: "btn small right" | |
| 80 | + = link_to "Add Public Key", new_key_path, class: "btn small" | |
| 75 | 81 | |
| 76 | 82 | .form-actions |
| 77 | 83 | = f.submit 'Save', class: "btn save-btn" | ... | ... |
config/gitlab.yml.example
| ... | ... | @@ -43,8 +43,6 @@ ldap: |
| 43 | 43 | |
| 44 | 44 | omniauth: |
| 45 | 45 | enabled: false |
| 46 | - allow_single_sign_on: false | |
| 47 | - block_auto_created_users: true | |
| 48 | 46 | providers: |
| 49 | 47 | # - { name: 'google_oauth2', app_id: 'YOUR APP ID', |
| 50 | 48 | # app_secret: 'YOUR APP SECRET', |
| ... | ... | @@ -53,6 +51,10 @@ omniauth: |
| 53 | 51 | # app_secret: 'YOUR APP SECRET'} |
| 54 | 52 | # - { name: 'github', app_id: 'YOUR APP ID', |
| 55 | 53 | # app_secret: 'YOUR APP SECRET' } |
| 54 | + # IMPORTANT! | |
| 55 | + # It allows user to login without having user account | |
| 56 | + allow_single_sign_on: false | |
| 57 | + block_auto_created_users: true | |
| 56 | 58 | |
| 57 | 59 | |
| 58 | 60 | # | ... | ... |