Skip to content

Commit

Permalink
Add enabled/disabled badge for OTP & Webauthn
Browse files Browse the repository at this point in the history
Co-authored-by: <betty.li@shopify.com>
  • Loading branch information
george-ma committed Jul 19, 2023
1 parent 125f034 commit cfc4d3d
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 18 deletions.
20 changes: 20 additions & 0 deletions app/assets/stylesheets/modules/badge.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
.badge {
display: inline;
background-color: #e1e1e1;
color: black;
border: 1px solid #c0c0c0;
border-radius: 5px;
padding: 5px 10px;
text-transform: uppercase;
font-size: 12px;
}

.badge--success {
background-color: #c4f2c7;
border-color: #9ecea1;
}

.badge--warning {
background-color: #fff6d2;
border-color: #dcd3b1;
}
10 changes: 10 additions & 0 deletions app/assets/stylesheets/modules/mfa.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
flex: 1;
}

.mfa__header-wrapper {
display: flex;
align-items: center;
gap: 20px;
}

.mfa__header.mfa__header--compact {
padding: 0;
}

@media (min-width: 780px) {
.mfa__container {
flex-direction: row;
Expand Down
29 changes: 20 additions & 9 deletions app/views/settings/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="t-body">
<h2 class="page__subheading"><%= t ".mfa.multifactor_auth" %></h2>
<% if @user.mfa_enabled? %>
<h2><%= t(".mfa.level.title")%></h2>
<h2 class="mfa__header mfa__header--compact"><%= t(".mfa.level.title")%></h2>
<p><%= t(".mfa.level_html") %></p>

<%= form_tag multifactor_auth_path, method: :put, id: "mfa-edit" do %>
Expand All @@ -13,9 +13,12 @@
<% end %>
<% end %>
<h2><%= t(".mfa.otp")%></h2>
<% if @user.totp_enabled? %>
<p><%= t(".mfa.enabled") %></p>
<div class="mfa__header-wrapper">
<h2 class="mfa__header mfa__header--compact"><%= t(".mfa.otp") %></h2>
<span class="badge badge--success"><%= t(".mfa.enabled") %></span>
</div>
<p><%= t(".mfa.enabled_note") %></p>
<%= form_tag multifactor_auth_path, method: :delete, id: "mfa-delete" do %>
<div class="text_field">
<%= label_tag :otp, t(".otp_code"), class: "form__label" %>
Expand All @@ -24,16 +27,24 @@
<%= submit_tag t(".mfa.disable"), class: "form__submit" %>
<% end %>
<% else %>
<div class="t-body">
<p>
<div class="mfa__header-wrapper">
<h2 class="mfa__header mfa__header--compact"><%= t(".mfa.otp") %></h2>
<span class="badge badge--warning"><%= t(".mfa.disabled") %></span>
</div>
<p>
<%= t(".mfa.disabled_html") %>
<%= button_to t(".mfa.go_settings"), new_multifactor_auth_path, method: "get", class: "form__submit" %>
</p>
</div>
</p>
<% end %>

<h2><%= t(".webauthn_credentials") %></h2>

<div class="mfa__header-wrapper">
<h2 class="mfa__header mfa__header--compact"><%= t(".webauthn_credentials") %></h2>
<% if @user.webauthn_enabled? %>
<span class="badge badge--success"><%= t(".mfa.enabled") %></span>
<% else %>
<span class="badge badge--warning"><%= t(".mfa.disabled") %></span>
<% end %>
</div>
<p><%= t(".webauthn_credential_note")%></p>

<% if @user.webauthn_credentials.none? %>
Expand Down
4 changes: 3 additions & 1 deletion config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,11 @@ de:
disabled_html:
go_settings:
level_html:
enabled:
enabled_note:
update:
disable:
enabled:
disabled:
level:
title:
disabled:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -455,10 +455,12 @@ en:
disabled_html: You have not yet enabled OTP based multi-factor authentication. Please refer to <a target="_blank" href="https://guides.rubygems.org/setting-up-multifactor-authentication">RubyGems MFA guide</a> for more information on MFA levels.
go_settings: Register a new device
level_html: You have enabled multi-factor authentication. Please click 'Update' to change your MFA level. Please refer to <a target="_blank" href="https://guides.rubygems.org/setting-up-multifactor-authentication">RubyGems MFA guide</a> for more information on MFA levels.
enabled: You have enabled multi-factor authentication. Please input your OTP from your authenticator or one of your active
enabled_note: You have enabled multi-factor authentication. Please input your OTP from your authenticator or one of your active
recovery codes to disable it.
update: Update
disable: Disable
enabled: Enabled
disabled: Disabled
level:
title: MFA Level
disabled: Disabled
Expand Down
4 changes: 3 additions & 1 deletion config/locales/es.yml
Original file line number Diff line number Diff line change
Expand Up @@ -479,9 +479,11 @@ es:
disabled_html:
go_settings: Registrar un nuevo dispositivo
level_html:
enabled:
enabled_note:
update: Actualizar
disable:
enabled:
disabled:
level:
title: Nivel de Autenticación de Múltiples Factores
disabled: Desactivada
Expand Down
4 changes: 3 additions & 1 deletion config/locales/fr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -481,9 +481,11 @@ fr:
disabled_html:
go_settings: Enregistrer un nouvel appareil
level_html:
enabled:
enabled_note:
update:
disable:
enabled:
disabled:
level:
title:
disabled:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,11 @@ ja:
disabled_html:
go_settings:
level_html:
enabled:
enabled_note:
update:
disable:
enabled:
disabled:
level:
title:
disabled:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/nl.yml
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,11 @@ nl:
disabled_html:
go_settings:
level_html:
enabled:
enabled_note:
update:
disable:
enabled:
disabled:
level:
title:
disabled:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -473,9 +473,11 @@ pt-BR:
disabled_html:
go_settings:
level_html:
enabled:
enabled_note:
update:
disable:
enabled:
disabled:
level:
title:
disabled:
Expand Down
4 changes: 3 additions & 1 deletion config/locales/zh-CN.yml
Original file line number Diff line number Diff line change
Expand Up @@ -444,9 +444,11 @@ zh-CN:
disabled_html:
go_settings: 注册新装置
level_html:
enabled:
enabled_note:
update: 更新
disable:
enabled:
disabled:
level:
title: 多重验证等级
disabled: 停用
Expand Down
4 changes: 3 additions & 1 deletion config/locales/zh-TW.yml
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,11 @@ zh-TW:
disabled_html:
go_settings: 註冊新裝置
level_html:
enabled:
enabled_note:
update: 更新
disable:
enabled:
disabled:
level:
title: 多重驗證等級
disabled: 停用
Expand Down

0 comments on commit cfc4d3d

Please sign in to comment.