<%= form_for @user, url: (@user.new? ? CartoDB.url(self, 'create_organization_user', user: current_user) : CartoDB.url(self, 'update_organization_user', params: { id: @user.username }, user: current_user)), :html => {:class => 'Form js-organizationUserForm CDB-Text'} do |f| %> <%= f.hidden_field :private_tables_enabled %> <%= hidden_field_tag :show_account_settings_flash, true %> <%= csrf_meta_tags %>
<%= f.text_field :username, :class => "CDB-InputText CDB-Text FormAccount-input FormAccount-input--med #{ 'is-disabled' if !@user.new? } #{ 'has-error' if @user.errors[:username].present? }", :readonly => !@user.new? %>
<% if (@user.errors[:username].present?) %>

Username not valid

<% elsif @user.new? %>

Once you choose the username, you won't be able to change it

<% end %>
<%= f.text_field :email, :class => "CDB-InputText CDB-Text FormAccount-input FormAccount-input--med #{ 'is-disabled' if !@user.can_change_email? } #{ 'has-error' if @user.errors[:email].present? }", readonly: !@user.can_change_email? %>
<% if (@user.errors[:email].present?) %>

Email not valid

<% elsif @user.new? %>

We encourage you to choose an email from your organization

<% end %>
<% if @organization.auth_username_password_enabled %>
<%= password_field_tag 'user[password]', nil, :placeholder => "New password", :class => "CDB-InputText CDB-Text FormAccount-input FormAccount-input--med #{ 'is-disabled' if !@user.can_change_password? } #{ 'has-error' if @user.errors[:password].present? }", readonly: !@user.can_change_password? %>
<% if (@user.errors[:password].present?) %>

<%= @user.errors[:password].first%>

<% end %>
<%= password_field_tag 'user[password_confirmation]', nil, :placeholder => "Confirm new password", :class => "CDB-InputText CDB-Text FormAccount-input FormAccount-input--med #{ 'is-disabled' if !@user.can_change_password? } #{ 'has-error' if @user.errors[:password].present?}", readonly: !@user.can_change_password? %>
<% end %>
<%= @organization.remaining_seats > 0 || @user.builder? ? '' : 'disabled' %> required>

Build and read

<% admin_editing_admin = @user.organization_admin? && !current_user.organization_owner? %>
<%= (@organization.remaining_viewer_seats == 0 && !@user.viewer?) || @user.organization_owner? || admin_editing_admin ? 'disabled' : '' %> required>

<% if @user.organization_owner? %> The organization owner cannot be a viewer user. <% elsif admin_editing_admin %> Organization admins can only be builder users. <% elsif @organization.viewer_seats == 0 %> You don't have viewer seats activated. Contact support for more information. <% else %> Only read <% end %>

<% if !@user.organization_owner? %>
>
<%= f.check_box :org_admin, id: "org_admin", disabled: !current_user.organization_owner? %> <%= label_tag(:org_admin, '') %>

<% if current_user.organization_owner? %> User has permission to manage users and groups and send notifications <% else %> Only the organization owner can assign administrator rights <% end %>

<% end %> <% mfa_configured = @user.multifactor_authentication_configured? %>
<%= f.check_box :mfa, id: "mfa", checked: mfa_configured %> <%= label_tag(:mfa, '') %>

If you change the Multi-factor authentication, it will be available only for this user. When you change the status, the user will be logged out and redirected to the login page.

<% if !@user.new? && current_user.organization_owner? && @user.engine_enabled? -%>
<%= f.text_field :api_key, :class => "CDB-InputText CDB-Text FormAccount-input FormAccount-input--med is-disabled", :readonly => true %>
<% end %> <% if @user.new? -%> <% if @organization.remaining_seats > 0 || @organization.remaining_viewer_seats > 0 %> <% else %> <% end %> <% elsif @user.editable_by?(current_user) %> <% if @user != current_user %> <% else %> <% end %> <% end %> <% end %>