From ba3392fb471237697ac59a7b6cb59c4daec4d431 Mon Sep 17 00:00:00 2001 From: Jez Caudle Date: Wed, 22 May 2024 09:54:22 +0100 Subject: [PATCH] Looking good. Webauthn integration time!! --- app/assets/stylesheets/application.css | 26 ++++++++++++-- app/views/credentials/_form.html.erb | 19 ++++------ app/views/credentials/new.html.erb | 6 ++-- app/views/devise/registrations/edit.html.erb | 38 +++++++------------- app/views/devise/sessions/new.html.erb | 36 +++++++------------ app/views/domains/_form.html.erb | 2 +- app/views/domains/new.html.erb | 8 ++--- app/views/layouts/application.html.erb | 4 +-- app/views/virtuals/_form.html.erb | 19 ++++------ app/views/virtuals/new.html.erb | 7 ++-- config/initializers/devise.rb | 2 +- 11 files changed, 75 insertions(+), 92 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index eecd148..75a6b65 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -70,6 +70,7 @@ body, html{ height: 100%; scroll-behavior: smooth; padding:1rem; + font-family:sans-serif; } /* @@ -89,12 +90,19 @@ menu > li { flex-grow: 1; } -.domain, .mfa { +main, .flash { background-color: #efefef; border-radius:1rem; padding:1rem; } -.domain-header, .mfa-header { + +.flash { + background-color: #dfcedf; + margin-bottom:1rem; + text-align: center; +} + +.domain-header, .mfa-header, h2 { background-color: #fefefe; border-radius:1rem; padding:1rem 1rem; @@ -108,7 +116,7 @@ menu > li { scale: 75%; } -.email-list, .domain-list, .mfa-list { +.email-list, .domain-list, .mfa-list, .work-area { border-radius:1rem; border:1rem black; background-color:#e7eae7; @@ -116,6 +124,17 @@ menu > li { margin:1rem 0; } +.work-area input { + padding:0.5rem; + margin:0.5rem; +} + +.work-area label { + padding:0.5rem; + margin:0.5rem; +} + + .email-list li { display: flex; margin:0.3rem 1rem; @@ -130,6 +149,7 @@ footer { background-color:#efefef; padding:1rem; border-radius:1rem; + text-align:center; } footer ul, footer h3 , footer li { diff --git a/app/views/credentials/_form.html.erb b/app/views/credentials/_form.html.erb index 5a9f25d..4aec554 100644 --- a/app/views/credentials/_form.html.erb +++ b/app/views/credentials/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_with(model: [@domain, credential]) do |form| %> +<%= form_with(model: [@domain, credential], html: { class: "work-area"}) do |form| %> <% if credential.errors.any? %>

<%= pluralize(credential.errors.count, "error") %> prohibited this credential from being saved:

@@ -11,17 +11,12 @@
<% end %> -
- <%= form.label :email, style: "display: inline" %> @<%=@domain.domain%> - <%= form.text_field :email %> -
+ <%= form.label :email %>:<%= form.text_field :email %>@<%=@domain.domain%> +
+ <%= form.label :password %>:<%= form.text_field :password %> +
-
- <%= form.label :password, style: "display: block" %> - <%= form.text_field :password %> -
-
- <%= form.submit %> -
+ <%= form.submit "Create email" %> + <% end %> diff --git a/app/views/credentials/new.html.erb b/app/views/credentials/new.html.erb index c9f0b5f..3f82d2d 100644 --- a/app/views/credentials/new.html.erb +++ b/app/views/credentials/new.html.erb @@ -1,9 +1,7 @@ -

New credential

+

New email for <%= @domain.domain %>

<%= render "form", credential: @credential %>
-
- <%= link_to "Back to the domain", domain_path(@domain) %> -
+<%= link_to "Back to the domain", domain_path(@domain) %> diff --git a/app/views/devise/registrations/edit.html.erb b/app/views/devise/registrations/edit.html.erb index 87415a2..5b83073 100644 --- a/app/views/devise/registrations/edit.html.erb +++ b/app/views/devise/registrations/edit.html.erb @@ -1,41 +1,29 @@

Edit <%= resource_name.to_s.humanize %>

-<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %> +<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'work-area' }) do |f| %> <%= render "devise/shared/error_messages", resource: resource %> -
- <%= f.label :email %>
- <%= f.email_field :email, autofocus: true, autocomplete: "email" %> -
+ <%= f.label :email %>:<%= f.email_field :email, autofocus: true, autocomplete: "email" %> <% if devise_mapping.confirmable? && resource.pending_reconfirmation? %>
Currently waiting confirmation for: <%= resource.unconfirmed_email %>
<% end %> -
- <%= f.label :password %> (leave blank if you don't want to change it)
- <%= f.password_field :password, autocomplete: "new-password" %> - <% if @minimum_password_length %> -
- <%= @minimum_password_length %> characters minimum - <% end %> -
+
+ <%= f.label :password %>:<%= f.password_field :password, autocomplete: "new-password" %> + <% if @minimum_password_length %><%= @minimum_password_length %> characters minimum<% end %> (leave blank if you don't want to change it) -
- <%= f.label :password_confirmation %>
- <%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
+
+ <%= f.label :password_confirmation %>:<%= f.password_field :password_confirmation, autocomplete: "new-password" %> -
- <%= f.label :current_password %> (we need your current password to confirm your changes)
- <%= f.password_field :current_password, autocomplete: "current-password" %> -
+
+ <%= f.label :current_password %>:<%= f.password_field :current_password, autocomplete: "current-password" %> +
(we need your current password to confirm your changes) -
- <%= f.submit "Update" %> -
+
+ <%= f.submit "Update" %> <% end %> -
+ <% if current_user.otp_secret.to_s.size == 0 %> <%= link_to "Enable MFA", new_mfa_path %> diff --git a/app/views/devise/sessions/new.html.erb b/app/views/devise/sessions/new.html.erb index 68b4714..cf81784 100644 --- a/app/views/devise/sessions/new.html.erb +++ b/app/views/devise/sessions/new.html.erb @@ -1,32 +1,22 @@

Log in

-
- <%= form_for(resource, as: resource_name, url: session_path(resource_name), class: "p-10 border shadow br-b-8 md-w-50pc mx-auto") do |f| %> -
- <%= f.label :email, class: "my-2" %> - <%= f.email_field :email, autofocus: true, autocomplete: "email", class:"input" %> -
-
- <%= f.label :password, class: "my-2" %> - <%= f.password_field :password, autocomplete: "current-password", class: "input" %> -
+<%= form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "work-area" } ) do |f| %> -
- <%= f.label :otp_attempt, class: "my-2" %> - <%= f.password_field :otp_attempt, autocomplete: "OTP Code", class: "input" %> -
+ <%= f.label :email %>:<%= f.email_field :email, autofocus: true, autocomplete: "email", class:"input" %> +
+ <%= f.label :password %>:<%= f.password_field :password, autocomplete: "current-password", class: "input" %> +
+ <%= f.label :otp_attempt %>:<%= f.password_field :otp_attempt, autocomplete: "OTP Code", class: "input" %> +
<% if devise_mapping.rememberable? %> -
- <%= f.check_box :remember_me, class: "checkbox mr-3" %> - <%= f.label :remember_me, class: "form-check-label" %> -
+ <%= f.label :remember_me %><%= f.check_box :remember_me %> <% end %> -
- <%= f.submit "Log in", class: "button" %> -
- <% end %> -
+
+ <%= f.submit "Log in", class: "button" %> + +<% end %> + <%= render "devise/shared/links" %> diff --git a/app/views/domains/_form.html.erb b/app/views/domains/_form.html.erb index 85b516f..bf82a15 100644 --- a/app/views/domains/_form.html.erb +++ b/app/views/domains/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_with(model: domain) do |form| %> +<%= form_with(model: domain, html: { class: "work-area" }) do |form| %> <% if domain.errors.any? %>

<%= pluralize(domain.errors.count, "error") %> prohibited this domain from being saved:

diff --git a/app/views/domains/new.html.erb b/app/views/domains/new.html.erb index 6c75318..ce2d6fb 100644 --- a/app/views/domains/new.html.erb +++ b/app/views/domains/new.html.erb @@ -1,9 +1,9 @@ -

New domain

+

New domain

<%= render "form", domain: @domain %>
-
- <%= link_to "Back to domains", domains_path %> -
+ +<%= link_to "Back to domains", domains_path %> + diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 92c96bb..45d089a 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -19,11 +19,9 @@
- + <% if notice %>
<%= notice %>
<% end %><% if alert %>
<%= alert %>
<% end %>
- <% if notice %>
<%= notice %>
<% end %> - <% if alert %>
<%= alert %>
<% end %> <%= yield %>
<% if Rails.env == "development" %> diff --git a/app/views/virtuals/_form.html.erb b/app/views/virtuals/_form.html.erb index 0af91b2..a2d53bc 100644 --- a/app/views/virtuals/_form.html.erb +++ b/app/views/virtuals/_form.html.erb @@ -1,4 +1,4 @@ -<%= form_with(model: [@domain,virtual]) do |form| %> +<%= form_with(model: [@domain,virtual], html: { class: "work-area"}) do |form| %> <% if virtual.errors.any? %>

<%= pluralize(virtual.errors.count, "error") %> prohibited this virtual from being saved:

@@ -11,17 +11,12 @@
<% end %> -
- <%= form.label :email, style: "display: block" %> - <%= form.text_field :email %> -
+ <%= form.label :email%>:<%= form.text_field :email %>@<%=@domain.domain%> +
-
- <%= form.label :destination, style: "display: block" %> - <%= form.text_field :destination %> -
+ <%= form.label :destination %>:<%= form.text_field :destination %> +
+ + <%= form.submit %> -
- <%= form.submit %> -
<% end %> diff --git a/app/views/virtuals/new.html.erb b/app/views/virtuals/new.html.erb index 1f96fc0..bebbf64 100644 --- a/app/views/virtuals/new.html.erb +++ b/app/views/virtuals/new.html.erb @@ -1,9 +1,8 @@ -

New virtual for <%= @domain.domain %>

+

New virtual for <%= @domain.domain %>

<%= render "form", virtual: @virtual %>
-
- <%= link_to "Back to #{@domain.domain}", domain_path(@domain) %> -
+<%= link_to "Back to #{@domain.domain}", domain_path(@domain) %> + diff --git a/config/initializers/devise.rb b/config/initializers/devise.rb index 72c8162..8002d60 100644 --- a/config/initializers/devise.rb +++ b/config/initializers/devise.rb @@ -232,7 +232,7 @@ Devise.setup do |config| # When set to false, does not sign a user in automatically after their password is # reset. Defaults to true, so a user is signed in automatically after a reset. - # config.sign_in_after_reset_password = true + config.sign_in_after_reset_password = false # ==> Configuration for :encryptable # Allow you to use another hashing or encryption algorithm besides bcrypt (default).