User flow updates

This commit is contained in:
2026-02-10 11:38:56 -05:00
parent 63b19cb78a
commit e624ec2d0b
38 changed files with 242 additions and 214 deletions
@@ -28,6 +28,12 @@
h3
color: $form-error-color
font-size: 1.2em
// Temporary hack for some forms
.control-group
.controls
.error
// compensate the margin-bottom of the input above
margin-top: -16px
body
label
&.number
@@ -1,3 +1,4 @@
# Contact page form
class ContactFormsController < ApplicationController
def create
@contact_form = Cmtool::ContactForm.new(contact_form_params)
@@ -1,4 +1,4 @@
class Suppliers::SessionsController < Devise::SessionsController
class Employees::SessionsController < Devise::SessionsController
respond_to :json
def create
@@ -10,6 +10,7 @@ class Suppliers::SessionsController < Devise::SessionsController
render json: {employee_id: current_employee.id, auth_token: current_employee.authentication_token}
end
# deprecated?
def destroy
session[:supplier_id] = nil
super
+5
View File
@@ -0,0 +1,5 @@
class ErrorsController < ApplicationController
def not_found
head :not_found # Renders an empty body with 404 status [5]
end
end
+13 -13
View File
@@ -1,13 +1,13 @@
class RegistrationsController < Devise::RegistrationsController
protected
#def after_sign_up_path(resource)
#end
private
# override devise internal to allow name as sign_up param
def sign_up_params
params.require(resource_name).permit resource_class.authentication_keys + [:name, :password, :password_confirmation]
end
end
# class RegistrationsController < Devise::RegistrationsController
# protected
#
# #def after_sign_up_path(resource)
# #end
#
# private
#
# # override devise internal to allow name as sign_up param
# def sign_up_params
# params.require(resource_name).permit resource_class.authentication_keys + [:name, :password, :password_confirmation]
# end
# end
@@ -0,0 +1,9 @@
class Users::RegistrationsController < Devise::RegistrationsController
def create
devise_parameter_sanitizer.permit(:sign_up, keys: [:name])
super
# if resource.persisted?
# self.response_body = nil
# end
end
end
+6
View File
@@ -0,0 +1,6 @@
class UsersController < ApplicationController
def show
authenticate_user!
@user = current_user
end
end
+20 -20
View File
@@ -1,20 +1,20 @@
class WaiterController < ApplicationController
layout 'waiter'
def index
end
def product_categories
respond_to do |format|
format.html { redirect_to '/waiter'}
format.json { render json: ProductCategory.all.include_relation(:product), root: 'product_categories', each_serializer: ProductCategorySerializer }
end
end
def order_products
@table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:table_id])
@list = List.from_table_by_employee(@table, current_employee)
@list.place_order products: params[:order], employee: current_employee
render nothing: true
end
end
# class WaiterController < ApplicationController
# layout 'waiter'
# def index
#
# end
#
# def product_categories
# respond_to do |format|
# format.html { redirect_to '/waiter'}
# format.json { render json: ProductCategory.all.include_relation(:product), root: 'product_categories', each_serializer: ProductCategorySerializer }
# end
# end
#
# def order_products
# @table= Table.find_by_supplier_id_and_id!(current_supplier.id, params[:table_id])
# @list = List.from_table_by_employee(@table, current_employee)
# @list.place_order products: params[:order], employee: current_employee
# render nothing: true
# end
# end
+1 -1
View File
@@ -14,7 +14,7 @@ class User
property :oauth_expires_at
property :auth_data
devise_plugins = [:database_authenticatable, :recoverable, :rememberable, :trackable, :omniauthable, {omniauth_providers: [:facebook, :instagram]}] #, :token_authenticatable , :registerable
devise_plugins = [:database_authenticatable, :registerable, :confirmable, :recoverable, :rememberable, :trackable] #, :omniauthable, {omniauth_providers: [:facebook, :instagram]}] #, :token_authenticatable , :registerable
devise_plugins -= [:trackable] if Rails.env.test? # creates conflicts
devise *devise_plugins
@@ -2,6 +2,7 @@ h2= t('devise.registrations.title')
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
- binding.pry
= f.label :name, class: 'control-label'
.controls= f.text_field :name
.control-group
@@ -15,5 +16,5 @@ h2= t('devise.registrations.title')
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.registrations.button'), class: 'btn btn-primary'
= render "devise_links"
= f.submit t('devise.registrations.button'), class: 'button2'
= render "devise/links"
@@ -1,29 +0,0 @@
<h2>Sign up</h2>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<div class="field">
<%= f.label :email %><br />
<%= f.email_field :email, autofocus: true %>
</div>
<div class="field">
<%= f.label :password %>
<% if @validatable %>
<em>(<%= @minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, autocomplete: "off" %>
</div>
<div class="field">
<%= f.label :password_confirmation %><br />
<%= f.password_field :password_confirmation, autocomplete: "off" %>
</div>
<div class="actions">
<%= f.submit "Sign up" %>
</div>
<% end %>
<%= render "devise/shared/links" %>
@@ -1,12 +0,0 @@
<h2>Resend confirmation instructions</h2>
<%= form_for(resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post }) do |f| %>
<%= devise_error_messages! %>
<div><%= f.label :email %><br />
<%= f.email_field :email %></div>
<div><%= f.submit "Resend confirmation instructions" %></div>
<% end %>
<%= render "links" %>
@@ -0,0 +1,11 @@
h2= t('devise.user.confirmations.title')
= form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
.control-group
.controls
= f.submit t('devise.user.confirmations.button'), class: 'button'
= render 'users/devise/links'
+23
View File
@@ -0,0 +1,23 @@
dl.devise-links
- devise_mapping = Devise.mappings[resource_name]
dt= t 'devise.links.prefix'
- if controller_name != 'sessions'
dd= link_to t('devise.user.sign_in.link'), new_session_path(resource_name), class: ['devise-link', 'new-session']
- if devise_mapping.registerable? && controller_name != 'registrations'
dd= link_to t('devise.user.registrations.link'), new_registration_path(resource_name), class: ['devise-link', 'new-registration']
- if resource_name == :employee and controller_name != 'new_suppliers'
dd= link_to t('devise.user.registrations.link'), new_suppliers_path, class: ['devise-link', 'new-registration']
- if devise_mapping.recoverable? && controller_name != 'passwords'
dd= link_to t('devise.user.passwords.link'), new_password_path(resource_name), class: ['devise-link', 'forgot-password']
- if devise_mapping.confirmable? && controller_name != 'confirmations'
dd= link_to t('devise.user.confirmations.did_not_receive_instructions_link'), new_confirmation_path(resource_name), class: ['devise-link', 'did-not-receive-instructions']
- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
dd= link_to t('devise.user.unlocks.did_not_receive_instructions_link'), new_unlock_path(resource_name), class: ['devise-link', 'did-not-receive-instructions']
- if devise_mapping.omniauthable?
- resource_class.omniauth_providers.each do |provider|
dd= link_to t('devise.user.omniauth_callbacks.sign_in_with', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: ['devise-link', 'omniauth', provider]
@@ -1,6 +1,6 @@
p= t('devise.mailer.confirmation_instructions.salutation', email: @resource.email)
p== t('mailer.user.confirmation_instructions.salutation', email: @resource.email)
p=raw t \
'devise.mailer.confirmation_instructions.body',
p== t \
'mailer.user.confirmation_instructions.body',
unconfirmed_email: @resource.unconfirmed_email,
confirm_url: confirmation_url(@resource, :confirmation_token => @token)
confirm_url: confirmation_url(@resource, confirmation_token: @token)
+3 -3
View File
@@ -1,4 +1,4 @@
h2= t('devise.passwords.edit.title')
h2= t('devise.user.passwords.edit.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal', method: :put}) do |f|
= devise_error_messages!
= f.hidden_field :reset_password_token
@@ -10,5 +10,5 @@ h2= t('devise.passwords.edit.title')
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.passwords.edit.button'), class: 'btn btn-primary'
= render "links"
= f.submit t('devise.user.passwords.edit.button'), class: 'button'
= render 'users/devise/links'
+3 -3
View File
@@ -1,4 +1,4 @@
h2= t('devise.passwords.title')
h2= t('devise.user.passwords.title')
= form_for(resource, :as => resource_name, :url => password_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
@@ -6,5 +6,5 @@ h2= t('devise.passwords.title')
.controls= f.email_field :email
.control-group
.controls
= f.submit t('devise.passwords.button'), class: 'btn btn-primary'
= render "links"
= f.submit t('devise.user.passwords.button'), class: 'button'
= render 'users/devise/links'
+13 -10
View File
@@ -1,19 +1,22 @@
h2= t('devise.registrations.title')
= form_for(resource, :as => resource_name, :url => registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
h2= t('devise.user.registrations.title')
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :name, class: 'control-label'
.controls= f.text_field :name
.control-group
= f.label :email, class: 'control-label'
.controls= f.email_field :email
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
- if f.object.errors[:email].present?
small.error= f.object.errors[:email].to_sentence
.control-group
= f.label :password, class: 'control-label'
.controls= f.password_field :password
= f.label :password, class: 'control-label'
.controls= f.password_field :password
.control-group
= f.label :password_confirmation, class: 'control-label'
.controls= f.password_field :password_confirmation
= f.label :password_confirmation, class: 'control-label'
.controls= f.password_field :password_confirmation
.control-group
.controls
= f.submit t('devise.registrations.button'), class: 'btn btn-primary'
= render "links"
= f.submit t('devise.user.registrations.button'), class: 'button'
= render 'users/devise/links'
+14 -8
View File
@@ -1,19 +1,25 @@
h2= t('devise.sessions.title')
h2= t('devise.user.sign_in.title')
= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: {class: 'form-horizontal'}) do |f|
= devise_error_messages!
.control-group
= f.label :email, class: 'control-label'
.controls= f.email_field :email
= f.label :email, class: 'control-label'
.controls
= f.email_field :email
- if f.object.errors[:email].present?
small.error= f.object.errors[:email].to_sentence
.control-group
= f.label :password, class: 'control-label'
.controls= f.password_field :password
= f.label :password, class: 'control-label'
.controls
= f.password_field :password
- if f.object.errors[:password].present?
small.error= f.object.errors[:password].to_sentence
.control-group
.controls
= f.label :remember_me do
= f.check_box :remember_me
|&nbsp;
= t('devise.sign_in.remember_me')
= t('devise.user.sign_in.remember_me')
.control-group
.controls
= f.submit t('devise.sign_in.button'), class: 'button'
= render "links"
= f.submit t('devise.user.sign_in.button'), class: 'button'
= render 'users/devise/links'