Commit fa4150d47d88b85d6027729844480a3e7c71d3cd

Authored by Dmitriy Zaporozhets
1 parent 486de8c3

Cleanup after omniauth

app/assets/stylesheets/auth_methods.scss
@@ -1,10 +0,0 @@ @@ -1,10 +0,0 @@
1 -.auth_methods {  
2 - ul {  
3 - margin: 0;  
4 - text-align:center;  
5 - padding: 5px;  
6 - li {  
7 - display: inline;  
8 - }  
9 - }  
10 -}  
app/assets/stylesheets/gitlab_bootstrap/blocks.scss
@@ -142,4 +142,8 @@ @@ -142,4 +142,8 @@
142 border:none; 142 border:none;
143 } 143 }
144 } 144 }
  145 +
  146 + .ui-box-body {
  147 + padding:10px;
  148 + }
145 } 149 }
app/assets/stylesheets/main.scss
@@ -134,7 +134,6 @@ $hover: #fdf5d9; @@ -134,7 +134,6 @@ $hover: #fdf5d9;
134 * TODO: clean it 134 * TODO: clean it
135 */ 135 */
136 @import "common.scss"; 136 @import "common.scss";
137 -@import "auth_methods.scss";  
138 137
139 /** 138 /**
140 * Styles related to specific part of app 139 * Styles related to specific part of app
app/controllers/omniauth_callbacks_controller.rb
1 class OmniauthCallbacksController < Devise::OmniauthCallbacksController 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 # Extend the standard message generation to accept our custom exception 8 # Extend the standard message generation to accept our custom exception
4 def failure_message 9 def failure_message
@@ -19,12 +24,6 @@ class OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController @@ -19,12 +24,6 @@ class OmniauthCallbacksController &lt; Devise::OmniauthCallbacksController
19 sign_in_and_redirect @user 24 sign_in_and_redirect @user
20 end 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 private 27 private
29 28
30 def handle_omniauth 29 def handle_omniauth
app/helpers/application_helper.rb
@@ -137,7 +137,8 @@ module ApplicationHelper @@ -137,7 +137,8 @@ module ApplicationHelper
137 end 137 end
138 138
139 def authbutton(provider, size = 64) 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 end 143 end
143 end 144 end
app/views/devise/sessions/new.html.haml
@@ -15,7 +15,8 @@ @@ -15,7 +15,8 @@
15 .right 15 .right
16 = render :partial => "devise/shared/links" 16 = render :partial => "devise/shared/links"
17 - if devise_mapping.omniauthable? 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,11 +19,11 @@
19 = f.label :password_confirmation 19 = f.label :password_confirmation
20 .input= f.password_field :password_confirmation 20 .input= f.password_field :password_confirmation
21 21
22 - - if Settings.omniauth.enabled 22 + - if Gitlab.config.omniauth_enabled?
23 .span5.right 23 .span5.right
24 - .auth_methods.alert.alert-info 24 + .alert.alert-info
25 %strong Tip: Use one of the following sites to login 25 %strong Tip: Use one of the following sites to login
26 - %ul 26 + %ul.unstyled
27 - User.omniauth_providers.each do |provider| 27 - User.omniauth_providers.each do |provider|
28 %li= link_to authbutton(provider), | 28 %li= link_to authbutton(provider), |
29 omniauth_authorize_path(User, provider) | 29 omniauth_authorize_path(User, provider) |
app/views/profile/show.html.haml
@@ -50,28 +50,34 @@ @@ -50,28 +50,34 @@
50 %strong Tip: 50 %strong Tip:
51 You can change your avatar at gravatar.com 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 .form-actions 82 .form-actions
77 = f.submit 'Save', class: "btn save-btn" 83 = f.submit 'Save', class: "btn save-btn"
config/gitlab.yml.example
@@ -43,8 +43,6 @@ ldap: @@ -43,8 +43,6 @@ ldap:
43 43
44 omniauth: 44 omniauth:
45 enabled: false 45 enabled: false
46 - allow_single_sign_on: false  
47 - block_auto_created_users: true  
48 providers: 46 providers:
49 # - { name: 'google_oauth2', app_id: 'YOUR APP ID', 47 # - { name: 'google_oauth2', app_id: 'YOUR APP ID',
50 # app_secret: 'YOUR APP SECRET', 48 # app_secret: 'YOUR APP SECRET',
@@ -53,6 +51,10 @@ omniauth: @@ -53,6 +51,10 @@ omniauth:
53 # app_secret: 'YOUR APP SECRET'} 51 # app_secret: 'YOUR APP SECRET'}
54 # - { name: 'github', app_id: 'YOUR APP ID', 52 # - { name: 'github', app_id: 'YOUR APP ID',
55 # app_secret: 'YOUR APP SECRET' } 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 #