OSDN Git Service

Read-only email field for LDAP user
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 27 Nov 2013 08:32:37 +0000 (10:32 +0200)
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Wed, 27 Nov 2013 08:32:37 +0000 (10:32 +0200)
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
app/controllers/profiles_controller.rb
app/views/profiles/show.html.haml

index 47cfc5e..9234cd1 100644 (file)
@@ -13,6 +13,8 @@ class ProfilesController < ApplicationController
   end
 
   def update
+    params[:user].delete(:email) if @user.ldap_user?
+
     if @user.update_attributes(params[:user])
       flash[:notice] = "Profile was successfully updated"
     else
index d382d2d..c22e00d 100644 (file)
         .controls
           = f.text_field :name, class: "input-xlarge", required: true
           %span.help-block Enter your name, so people you know can recognize you.
+
       .control-group
         = f.label :email, class: "control-label"
         .controls
-          = f.text_field :email, class: "input-xlarge", required: true
-          - if @user.unconfirmed_email.present?
-            %span.help-block
-              We sent confirmation email to
-              %strong #{@user.unconfirmed_email}
+          - if @user.ldap_user?
+            = f.text_field :email, class: "input-xlarge", required: true, readonly: true
+            %span.help-block.light
+              Email is read-only for LDAP user
           - else
-            %span.help-block We also use email for avatar detection if no avatar is uploaded.
+            = f.text_field :email, class: "input-xlarge", required: true
+            - if @user.unconfirmed_email.present?
+              %span.help-block
+                We sent confirmation email to
+                %strong #{@user.unconfirmed_email}
+            - else
+              %span.help-block We also use email for avatar detection if no avatar is uploaded.
       .control-group
         = f.label :skype, class: "control-label"
         .controls= f.text_field :skype, class: "input-xlarge"