diff options
-rw-r--r-- | app/helpers/application_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/oauth_helper.rb | 13 | ||||
-rw-r--r-- | app/views/devise/sessions/_new_base.html.haml | 13 | ||||
-rw-r--r-- | app/views/devise/sessions/_new_ldap.html.haml | 28 | ||||
-rw-r--r-- | app/views/devise/sessions/_oauth_providers.html.haml | 10 | ||||
-rw-r--r-- | app/views/devise/sessions/new.html.haml | 59 | ||||
-rw-r--r-- | config/gitlab.yml.example | 2 |
7 files changed, 69 insertions, 60 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index ef90a8877ee..65d03fe0ccd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -119,10 +119,6 @@ module ApplicationHelper Emoji.names.to_s end - def ldap_enable? - Devise.omniauth_providers.include?(:ldap) - end - def app_theme Gitlab::Theme.css_class_by_id(current_user.try(:theme_id)) end diff --git a/app/helpers/oauth_helper.rb b/app/helpers/oauth_helper.rb new file mode 100644 index 00000000000..017c22d9e1f --- /dev/null +++ b/app/helpers/oauth_helper.rb @@ -0,0 +1,13 @@ +module OauthHelper + def ldap_enabled? + Devise.omniauth_providers.include?(:ldap) + end + + def default_providers + [:twitter, :github, :google_oauth2, :ldap] + end + + def enabled_oauth_providers + Devise.omniauth_providers + end +end diff --git a/app/views/devise/sessions/_new_base.html.haml b/app/views/devise/sessions/_new_base.html.haml new file mode 100644 index 00000000000..1ca43d5dd08 --- /dev/null +++ b/app/views/devise/sessions/_new_base.html.haml @@ -0,0 +1,13 @@ += form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| + = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" + = f.password_field :password, class: "text bottom", placeholder: "Password" + - if devise_mapping.rememberable? + .clearfix.inputs-list + %label.checkbox.remember_me{for: "user_remember_me"} + = f.check_box :remember_me + %span Remember me + = f.submit "Sign in", class: "btn-create btn" + .pull-right + = link_to "Forgot your password?", new_password_path(resource_name), class: "btn" + + diff --git a/app/views/devise/sessions/_new_ldap.html.haml b/app/views/devise/sessions/_new_ldap.html.haml index 29ba9c1e99c..575d33949b6 100644 --- a/app/views/devise/sessions/_new_ldap.html.haml +++ b/app/views/devise/sessions/_new_ldap.html.haml @@ -1,29 +1,5 @@ -= form_tag(user_omniauth_callback_path(:ldap), class: "login-box", id: 'new_ldap_user' ) do - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" += form_tag(user_omniauth_callback_path(:ldap), id: 'new_ldap_user' ) do = text_field_tag :username, nil, {class: "text top", placeholder: "LDAP Login", autofocus: "autofocus"} = password_field_tag :password, nil, {class: "text bottom", placeholder: "Password"} %br/ - = submit_tag "LDAP Sign in", class: "btn-primary btn" - - if devise_mapping.omniauthable? - - (resource_class.omniauth_providers - [:ldap]).each do |provider| - %hr/ - = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), class: "btn btn-primary" - %br/ - %hr/ - %a#other_form_toggle{href: "#", onclick: "javascript:$('#new_user').toggle();"} Other Sign in - :javascript - $(function() { - $('#new_user').toggle(); - }); -= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "login-box" }) do |f| - = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" - = f.password_field :password, class: "text bottom", placeholder: "Password" - - if devise_mapping.rememberable? - .clearfix.inputs-list - %label.checkbox.remember_me{for: "user_remember_me"} - = f.check_box :remember_me - %span Remember me - %br/ - = f.submit "Sign in", class: "btn-primary btn" - .pull-right - = render partial: "devise/shared/links" + = submit_tag "LDAP Sign in", class: "btn-create btn" diff --git a/app/views/devise/sessions/_oauth_providers.html.haml b/app/views/devise/sessions/_oauth_providers.html.haml new file mode 100644 index 00000000000..710a5d52514 --- /dev/null +++ b/app/views/devise/sessions/_oauth_providers.html.haml @@ -0,0 +1,10 @@ +- if enabled_oauth_providers.present? + %hr + %div{:'data-no-turbolink' => 'data-no-turbolink'} + %span Sign in with: + - (enabled_oauth_providers - [:ldap]).each do |provider| + %span + - if default_providers.include?(provider) + = 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" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index baa232350a5..8b71ebed5f4 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,32 +1,31 @@ -- if ldap_enable? - = render partial: 'devise/sessions/new_ldap' -- else - = form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "login-box" }) do |f| - = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" - = f.text_field :login, class: "text top", placeholder: "Username or Email", autofocus: "autofocus" - = f.password_field :password, class: "text bottom", placeholder: "Password" - - if devise_mapping.rememberable? - .clearfix.inputs-list - %label.checkbox.remember_me{for: "user_remember_me"} - = f.check_box :remember_me - %span Remember me - %br/ - = f.submit "Sign in", class: "btn-create btn" - .pull-right - = link_to "Forgot your password?", new_password_path(resource_name), class: "btn" - %br/ - - if Gitlab.config.gitlab.signup_enabled - %hr/ +.login-box + = image_tag "login-logo.png", width: "304", height: "66", class: "login-logo", alt: "Login Logo" + + - if ldap_enabled? + %ul.nav.nav-tabs + %li.active + = link_to 'LDAP', '#tab-ldap', 'data-toggle' => 'tab' + %li + = link_to 'Ordinary', '#tab-signin', 'data-toggle' => 'tab' + .tab-content + %div#tab-ldap.tab-pane.active + = render partial: 'devise/sessions/new_ldap' + %div#tab-signin.tab-pane + = render partial: 'devise/sessions/new_base' + + - else + = render partial: 'devise/sessions/new_base' + + + = render 'devise/sessions/oauth_providers' if devise_mapping.omniauthable? + + - if Gitlab.config.gitlab.signup_enabled + %hr + %div Don't have an account? - = link_to "Sign up", new_registration_path(resource_name) - - if devise_mapping.omniauthable? && resource_class.omniauth_providers.present? - %hr - %div - %span Sign in with: - - resource_class.omniauth_providers.each do |provider| - %span - = link_to authbutton(provider, 32), omniauth_authorize_path(resource_name, provider) + %strong + = link_to "Sign up", new_registration_path(resource_name) - - if extra_config.has_key?('sign_in_text') - %hr - = markdown(extra_config.sign_in_text) + - if extra_config.has_key?('sign_in_text') + %hr + = markdown(extra_config.sign_in_text) diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example index 19b58bcc371..413560159d5 100644 --- a/config/gitlab.yml.example +++ b/config/gitlab.yml.example @@ -34,6 +34,8 @@ production: &base ## Project settings default_projects_limit: 10 + + ## Users management # signup_enabled: true # default: false - Account passwords are not sent via the email if signup is enabled. # username_changing_enabled: false # default: true - User can change her username/namespace |