Commit a3645b5b4d86b385f870b73784acb79f824918ff
1 parent
7cb86eb3
Exists in
master
and in
4 other branches
Restyle login page for LDAP/regular login
Showing
7 changed files
with
69 additions
and
60 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -0,0 +1,13 @@ |
1 | +module OauthHelper | |
2 | + def ldap_enabled? | |
3 | + Devise.omniauth_providers.include?(:ldap) | |
4 | + end | |
5 | + | |
6 | + def default_providers | |
7 | + [:twitter, :github, :google_oauth2, :ldap] | |
8 | + end | |
9 | + | |
10 | + def enabled_oauth_providers | |
11 | + Devise.omniauth_providers | |
12 | + end | |
13 | +end | ... | ... |
... | ... | @@ -0,0 +1,13 @@ |
1 | += form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| | |
2 | + = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" | |
3 | + = f.password_field :password, class: "text bottom", placeholder: "Password" | |
4 | + - if devise_mapping.rememberable? | |
5 | + .clearfix.inputs-list | |
6 | + %label.checkbox.remember_me{for: "user_remember_me"} | |
7 | + = f.check_box :remember_me | |
8 | + %span Remember me | |
9 | + = f.submit "Sign in", class: "btn-create btn" | |
10 | + .pull-right | |
11 | + = link_to "Forgot your password?", new_password_path(resource_name), class: "btn" | |
12 | + | |
13 | + | ... | ... |
app/views/devise/sessions/_new_ldap.html.haml
1 | -= form_tag(user_omniauth_callback_path(:ldap), class: "login-box", id: 'new_ldap_user' ) do | |
2 | - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" | |
1 | += form_tag(user_omniauth_callback_path(:ldap), id: 'new_ldap_user' ) do | |
3 | 2 | = text_field_tag :username, nil, {class: "text top", placeholder: "LDAP Login", autofocus: "autofocus"} |
4 | 3 | = password_field_tag :password, nil, {class: "text bottom", placeholder: "Password"} |
5 | 4 | %br/ |
6 | - = submit_tag "LDAP Sign in", class: "btn-primary btn" | |
7 | - - if devise_mapping.omniauthable? | |
8 | - - (resource_class.omniauth_providers - [:ldap]).each do |provider| | |
9 | - %hr/ | |
10 | - = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), class: "btn btn-primary" | |
11 | - %br/ | |
12 | - %hr/ | |
13 | - %a#other_form_toggle{href: "#", onclick: "javascript:$('#new_user').toggle();"} Other Sign in | |
14 | - :javascript | |
15 | - $(function() { | |
16 | - $('#new_user').toggle(); | |
17 | - }); | |
18 | -= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "login-box" }) do |f| | |
19 | - = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" | |
20 | - = f.password_field :password, class: "text bottom", placeholder: "Password" | |
21 | - - if devise_mapping.rememberable? | |
22 | - .clearfix.inputs-list | |
23 | - %label.checkbox.remember_me{for: "user_remember_me"} | |
24 | - = f.check_box :remember_me | |
25 | - %span Remember me | |
26 | - %br/ | |
27 | - = f.submit "Sign in", class: "btn-primary btn" | |
28 | - .pull-right | |
29 | - = render partial: "devise/shared/links" | |
5 | + = submit_tag "LDAP Sign in", class: "btn-create btn" | ... | ... |
... | ... | @@ -0,0 +1,10 @@ |
1 | +- if enabled_oauth_providers.present? | |
2 | + %hr | |
3 | + %div{:'data-no-turbolink' => 'data-no-turbolink'} | |
4 | + %span Sign in with: | |
5 | + - (enabled_oauth_providers - [:ldap]).each do |provider| | |
6 | + %span | |
7 | + - if default_providers.include?(provider) | |
8 | + = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) | |
9 | + - else | |
10 | + = link_to provider.to_s.titleize, omniauth_authorize_path(resource_name, provider), class: "btn" | ... | ... |
app/views/devise/sessions/new.html.haml
1 | -- if ldap_enable? | |
2 | - = render partial: 'devise/sessions/new_ldap' | |
3 | -- else | |
4 | - = form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "login-box" }) do |f| | |
5 | - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" | |
6 | - = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" | |
7 | - = f.password_field :password, class: "text bottom", placeholder: "Password" | |
8 | - - if devise_mapping.rememberable? | |
9 | - .clearfix.inputs-list | |
10 | - %label.checkbox.remember_me{for: "user_remember_me"} | |
11 | - = f.check_box :remember_me | |
12 | - %span Remember me | |
13 | - %br/ | |
14 | - = f.submit "Sign in", class: "btn-create btn" | |
15 | - .pull-right | |
16 | - = link_to "Forgot your password?", new_password_path(resource_name), class: "btn" | |
17 | - %br/ | |
18 | - - if Gitlab.config.gitlab.signup_enabled | |
19 | - %hr/ | |
1 | +.login-box | |
2 | + = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" | |
3 | + | |
4 | + - if ldap_enabled? | |
5 | + %ul.nav.nav-tabs | |
6 | + %li.active | |
7 | + = link_to 'LDAP', '#tab-ldap', 'data-toggle' => 'tab' | |
8 | + %li | |
9 | + = link_to 'Ordinary', '#tab-signin', 'data-toggle' => 'tab' | |
10 | + .tab-content | |
11 | + %div#tab-ldap.tab-pane.active | |
12 | + = render partial: 'devise/sessions/new_ldap' | |
13 | + %div#tab-signin.tab-pane | |
14 | + = render partial: 'devise/sessions/new_base' | |
15 | + | |
16 | + - else | |
17 | + = render partial: 'devise/sessions/new_base' | |
18 | + | |
19 | + | |
20 | + = render 'devise/sessions/oauth_providers' if devise_mapping.omniauthable? | |
21 | + | |
22 | + - if Gitlab.config.gitlab.signup_enabled | |
23 | + %hr | |
24 | + %div | |
20 | 25 | Don't have an account? |
21 | - = link_to "Sign up", new_registration_path(resource_name) | |
22 | - - if devise_mapping.omniauthable? && resource_class.omniauth_providers.present? | |
23 | - %hr | |
24 | - %div | |
25 | - %span Sign in with: | |
26 | - - resource_class.omniauth_providers.each do |provider| | |
27 | - %span | |
28 | - = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) | |
26 | + %strong | |
27 | + = link_to "Sign up", new_registration_path(resource_name) | |
29 | 28 | |
30 | - - if extra_config.has_key?('sign_in_text') | |
31 | - %hr | |
32 | - = markdown(extra_config.sign_in_text) | |
29 | + - if extra_config.has_key?('sign_in_text') | |
30 | + %hr | |
31 | + = markdown(extra_config.sign_in_text) | ... | ... |
config/gitlab.yml.example
... | ... | @@ -34,6 +34,8 @@ production: &base |
34 | 34 | |
35 | 35 | ## Project settings |
36 | 36 | default_projects_limit: 10 |
37 | + | |
38 | + ## Users management | |
37 | 39 | # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. |
38 | 40 | # username_changing_enabled: false # default: true - User can change her username/namespace |
39 | 41 | ... | ... |