Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-18 20:22:24 +0400
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2014-03-18 20:22:24 +0400
commite4a7dae329d3d77d250e0aa252bd127565919b70 (patch)
treef60f9ca5d58516012ce8d417de19daf1a38a1132
parent8fa53ce43dff48a3e282460c9f9f40dbdfee6e12 (diff)
parenta740e2d6d16271c2e3d06252e35e65b10d002834 (diff)
Merge branch 'ldap_password' into 'master'
Prevent LDAP users from using reset password function
-rw-r--r--app/controllers/passwords_controller.rb18
-rw-r--r--config/routes.rb2
2 files changed, 19 insertions, 1 deletions
diff --git a/app/controllers/passwords_controller.rb b/app/controllers/passwords_controller.rb
new file mode 100644
index 00000000000..988ede3007b
--- /dev/null
+++ b/app/controllers/passwords_controller.rb
@@ -0,0 +1,18 @@
+class PasswordsController < Devise::PasswordsController
+
+ def create
+ email = resource_params[:email]
+ resource_found = resource_class.find_by_email(email)
+ if resource_found && resource_found.ldap_user?
+ flash[:alert] = "Cannot reset password for LDAP user."
+ respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name)) and return
+ end
+
+ self.resource = resource_class.send_reset_password_instructions(resource_params)
+ if successfully_sent?(resource)
+ respond_with({}, :location => after_sending_reset_password_instructions_path_for(resource_name))
+ else
+ respond_with(resource)
+ end
+ end
+end
diff --git a/config/routes.rb b/config/routes.rb
index 628d1f631bc..709b66d3e06 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -167,7 +167,7 @@ Gitlab::Application.routes.draw do
resources :projects, constraints: { id: /[^\/]+/ }, only: [:new, :create]
- devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations }
+ devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords}
#
# Project Area