summaryrefslogtreecommitdiff
path: root/app/views/users/edit.html.erb
blob: ea5e7deccd34ac1252ab6a15d672302c2ed77564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<h1><%= @user == current_user ? t(".my_account") : t(".edit_user", :login => @user.login) %></h1>

<% if @user.errors.any? %>
  <div class="error_messages">
    <ul><% @user.errors.full_messages.each do |msg| %><li><%= msg %></li><% end %></ul>
  </div>
<% end %>

<div id="admin_layout">
  <%= form_for @user do |f| %>
  <div id="content">
    <div class="layout_row_label"><%= t(".login") %></div>
    <div class="layout_row_content"><%= f.text_field :login, :autocomplete => "username" %></div>

    <div class="layout_row_label"><%= t(".email") %></div>
    <div class="layout_row_content"><%= f.text_field :email %></div>

    <div class="layout_row_label"><%= t(".password") %></div>
    <div class="layout_row_content"><%= f.password_field :password, :autocomplete => "new-password" %></div>

    <div class="layout_row_label"><%= t(".confirm") %></div>
    <div class="layout_row_content"><%= f.password_field :password_confirmation, :autocomplete => "new-password" %></div>

    <% if current_user.admin? %>
    <div class="layout_row_label"><%= t(".admin") %></div>
    <div class="layout_row_content"><%= f.check_box :admin %></div>
    <% end %>

    <div class="layout_row_label"></div>
    <div class="layout_row_content"><%= submit_tag t(".update") %></div>
  <% end %>
  </div>

  <% if @user == current_user %>
    <div class="layout_row_label"><%= t(".second_factor") %></div>
    <div class="layout_row_content">
      <% if current_user.otp_enrolled? %>
        <p><%= t(".enabled") %></p>
        <%= form_tag otp_enrollment_path, :method => :delete, :class => "otp_form" do %>
          <%= text_field_tag :login, current_user.login, :autocomplete => "username", :readonly => true, :tabindex => -1, :class => "visually_hidden" %>
          <%= password_field_tag :current_password, nil, :placeholder => t(".current_password"), :autocomplete => "current-password" %>
          <%= text_field_tag :code, nil, :placeholder => t(".current_code"),
                :autocomplete => "one-time-code", :inputmode => "numeric" %>
          <%= button_tag :type => "submit", :class => "action_button" do %>
            <%= icon("shield-off", library: "tabler", "aria-hidden": true) %> <%= t(".disable_second_factor") %>
          <% end %>
        <% end %>
      <% else %>
        <p><%= t(".not_enrolled") %></p>
        <%= form_tag otp_enrollment_path, :method => :post, :class => "otp_form" do %>
          <%= text_field_tag :login, current_user.login, :autocomplete => "username", :readonly => true, :tabindex => -1, :class => "visually_hidden" %>
          <%= password_field_tag :current_password, nil, :placeholder => t(".current_password"), :autocomplete => "current-password"%>
          <%= button_tag :type => "submit", :class => "action_button" do %>
            <%= icon("shield-lock", library: "tabler", "aria-hidden": true) %> <%= t(".enable_second_factor") %>
          <% end %>
        <% end %>
      <% end %>
    </div>
  <% elsif current_user.admin? && @user.otp_enrolled? %>
    <div class="layout_row_label"><%= t(".second_factor") %></div>
    <div class="layout_row_content">
      <%= t(".enabled") %>
      <%= button_to t(".reset_second_factor"), reset_otp_user_path(@user), :method => :put,
            :form_class => "button_to destructive",
            :form => { :data => { :confirm => t(".reset_confirm", :login => @user.login) } } %>
    </div>
  <% end %>
</div>