Commit 366e6533 by Mai Hoang Thai Ha

fixed register

parent 7c9f8479
......@@ -9,7 +9,7 @@ class ApplicationController < ActionController::Base
def configure_permitted_parameters
devise_parameter_sanitizer.permit :sign_up, keys: %i[name address phone email password]
devise_parameter_sanitizer.permit :account_update, keys: %i[name email address phone password current_password]
devise_parameter_sanitizer.permit :account_update, keys: %i[name email address phone password]
end
private
......
......@@ -2,9 +2,6 @@
class Users::ConfirmationsController < Devise::ConfirmationsController
# GET /resource/confirmation/new
# def new
# super
# end
# POST /resource/confirmation
# def create
......@@ -19,7 +16,8 @@ class Users::ConfirmationsController < Devise::ConfirmationsController
protected
def after_confirmation_path_for(resource_name, resource)
sign_in(resource)
token = resource.send(:set_reset_password_token)
edit_password_path(resource, reset_password_token: token)
signup_infomation_path(reset_password_token: token)
end
end
......@@ -4,59 +4,15 @@ class Users::RegistrationsController < Devise::RegistrationsController
# before_action :configure_sign_up_params, only: [:create]
# before_action :configure_account_update_params, only: [:update]
# GET /resource/sign_up
# def new
# super
# end
def information
self.resource = resource_class.new
signed_in_resource
render :infomation
end
# POST /resource
# def create
# super
# end
protected
# GET /resource/edit
# def edit
# super
# end
# PUT /resource
# def update
# super
# end
# DELETE /resource
# def destroy
# super
# end
# GET /resource/cancel
# Forces the session data which is usually expired after sign
# in to be expired now. This is useful if the user wants to
# cancel oauth signing in/up in the middle of the process,
# removing all OAuth session data.
# def cancel
# super
# end
# protected
# If you have extra params to permit, append them to the sanitizer.
# def configure_sign_up_params
# devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
# end
# If you have extra params to permit, append them to the sanitizer.
# def configure_account_update_params
# devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
# end
# The path used after sign up.
# def after_sign_up_path_for(resource)
# super(resource)
# end
# The path used after sign up for inactive accounts.
# def after_inactive_sign_up_path_for(resource)
# super(resource)
# end
def update_resource(resource, params)
resource.update_without_password(params)
end
end
......@@ -13,4 +13,4 @@ header.navbar.navbar-fixed-top.navbar-inverse
li
= link_to "Log in", login_path
li
= link_to "Sign up", new_user_registration_path
= link_to "Sign up", signup_path
- provide(:title, 'Forgot password')
.container
.row.justify-content-center
.col-6
h2.text-center.my-5
| Forgot password
= form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
= render 'users/shared/error_messages', resource: resource
.field.row.form-group.mb-4
.col-2
= f.label :email, class: 'form-label'
.col-10
= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-10.d-flex.justify-content-center
= f.submit 'Confirm your email', class: 'btn btn-primary w-75 my-4', data: { disable_with: false }
javascript:
Validator({
form: '#new_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_email'),
Validator.isEmail('#user_email')
]
})
......@@ -55,12 +55,6 @@
.col-9
= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :current_password, class: 'form-label'
.col-9
= f.password_field :current_password, autocomplete: 'current-password', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-9
= f.submit 'Done', class: 'btn btn-primary w-50 my-4', data: { disable_with: false }
......@@ -81,10 +75,6 @@ javascript:
Validator.isEmail('#user_email'),
Validator.isRequired('#user_name'),
Validator.isRequired('#user_address'),
Validator.isRequired('#user_phone'),
Validator.isRequired('#user_current_password'),
Validator.isConfirmed('#user_password_confirmation', function() {
return document.querySelector('#new_user #user_password').value;
}, 'Those passwords didn’t match.'),
Validator.isRequired('#user_phone')
]
})
\ No newline at end of file
- provide(:title, 'Edit profile')
.container
.row.justify-content-center
.col-8
h2.text-center.my-5
| Register
= resource_name.to_s.humanize
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
= render 'users/shared/error_messages', resource: resource
.field.row.mb-2.form-group
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
div
| Currently waiting confirmation for:
= resource.unconfirmed_email
.field.row.mb-2.form-group
.col-3
= f.label :name, class: 'form-label'
.col-9
= f.text_field :name, autofocus: true, autocomplete: 'name', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :address, class: 'form-label'
.col-9
= f.text_field :address, autofocus: true, autocomplete: 'address', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :phone, class: 'form-label'
.col-9
= f.text_field :phone, autofocus: true, autocomplete: 'phone', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :password, class: 'form-label'
.col-9
= f.password_field :password, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :password_confirmation, class: 'form-label'
.col-9
= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-9
= f.submit 'Register', class: 'btn btn-primary w-50 my-4', data: { disable_with: false }
/ javascript:
Validator({
form: '#edit_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_email'),
Validator.isEmail('#user_email'),
Validator.isRequired('#user_name'),
Validator.isRequired('#user_address'),
Validator.isRequired('#user_phone'),
Validator.isRequired('#user_current_password')
]
})
\ No newline at end of file
Rails.application.routes.draw do
devise_for :users, controllers: {
sessions: 'users/sessions', confirmations: 'users/confirmations'
sessions: 'users/sessions',
confirmations: 'users/confirmations',
registrations: 'users/registrations'
}
devise_scope :user do
get '/login', to: 'devise/sessions#new', as: :login
get '/my/info', to: 'devise/registrations#edit', as: :edit_profile
get '/forgot_password', to: 'devise/passwords#new', as: :forgot_password
get '/reset_password', to: 'devise/passwords#edit', as: :reset_password
get '/register/1', to: 'devise/registrations#new', as: :signup
get '/register/3', to: 'users/registrations#information', as: :signup_infomation
end
root 'top#index'
......
- provide(:title, 'Edit profile')
.container
.row.justify-content-center
.col-8
h2.text-center.my-5
| Register
= resource_name.to_s.humanize
= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
= render 'users/shared/error_messages', resource: resource
.field.row.mb-2.form-group
.col-3
= f.label :email, class: 'form-label'
.col-9
= f.email_field :email, autofocus: true, autocomplete: 'email', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
- if devise_mapping.confirmable? && resource.pending_reconfirmation?
div
| Currently waiting confirmation for:
= resource.unconfirmed_email
.field.row.mb-2.form-group
.col-3
= f.label :name, class: 'form-label'
.col-9
= f.text_field :name, autofocus: true, autocomplete: 'name', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :address, class: 'form-label'
.col-9
= f.text_field :address, autofocus: true, autocomplete: 'address', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :phone, class: 'form-label'
.col-9
= f.text_field :phone, autofocus: true, autocomplete: 'phone', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :password, class: 'form-label'
.col-9
= f.password_field :password, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.field.row.mb-2.form-group
.col-3
= f.label :password_confirmation, class: 'form-label'
.col-9
= f.password_field :password_confirmation, autocomplete: 'new-password', class: 'form-control mb-2'
span.form-msg
.actions.row.justify-content-end
.col-9
= f.submit 'Register', class: 'btn btn-primary w-50 my-4', data: { disable_with: false }
/ javascript:
Validator({
form: '#edit_user',
errorSelector: '.form-msg',
rules: [
Validator.isRequired('#user_email'),
Validator.isEmail('#user_email'),
Validator.isRequired('#user_name'),
Validator.isRequired('#user_address'),
Validator.isRequired('#user_phone'),
Validator.isRequired('#user_current_password')
]
})
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment