change level of development.yml, add callback in reset_password

parent 4fc05e8f
Pipeline #1083 failed with stages
in 0 seconds
......@@ -6,12 +6,12 @@ class ConfirmationsController < ApplicationController
def mail_register
email = params[:confirmation][:email].downcase
if User.find_by(email: email)
flash[:danger] = Settings.sign_up.email_existed
flash[:danger] = Settings.user.sign_up.existed
redirect_to register_step1_path
end
@user = Confirmation.find_or_initialize_by(email: email)
unless @user.save
flash[:danger] = Settings.sign_up.email_format_failed
flash[:danger] = Settings.user.sign_up.format_failed
return redirect_to register_step1_path
end
......
class JobAppliedsController < ApplicationController
before_action :sign_in_validation, only: [:new, :confirmation, :create]
def new
end
def confirmation
@user = JobApplied.new(apply_params)
return root_path unless apply_params
end
def create
binding.pry
@user = JobApplied.new(apply_params)
return root_path unless @user
return job_detail_path(apply_params[:job_id]) unless @user.save
end
private
def sign_in_validation
return if signed_in?
flash[:warning] = Settings.user.warning_signin
redirect_to login_path
end
def apply_params
params.require(:job_applied).permit(:name, :email, :job_id, :cv_user)
end
end
class ResetPasswordsController < ApplicationController
before_action :find_token_param, only: [:edit]
def reset_password
end
......@@ -6,20 +7,19 @@ class ResetPasswordsController < ApplicationController
def sending_email
@user = User.find_by(email: params[:reset_password][:email].downcase)
unless @user
flash[:danger] = Settings.reset_password.sending_email_failed
redirect_to reset_password_step1_path
flash[:danger] = Settings.user.reset_password.failed
else
forgot_token = Digest::SHA1.hexdigest(SecureRandom.urlsafe_base64)
@user.update_attribute(:remember_token, forgot_token)
ResetPasswordMailer.reset_password(@user).deliver_later
flash[:success] = Settings.reset_password.sending_email_success
redirect_to reset_password_step1_path
flash[:success] = Settings.user.reset_password.success
end
redirect_to reset_password_step1_path
end
def edit
@user = User.find_by(remember_token: params[:token])
return redirect_to reset_password_step1_path unless @user && params[:token]
return redirect_to reset_password_step1_path unless @user
if @user.token_expired?
flash[:danger] = Settings.user.expiration
redirect_to register_step1_path
......@@ -28,18 +28,22 @@ class ResetPasswordsController < ApplicationController
def update
@user = User.find_by(email: params[:user][:email])
unless @user.update_attributes(forgot_pass_params)
flash[:danger] = Settings.reset_password.update_reset_pass
redirect_to reset_password_final_path(token: @user.remember_token)
else
if @user.update_attributes(forgot_pass_params)
sign_in @user
flash[:success] = Settings.general_notify.update_success
redirect_to my_page_path
else
flash[:danger] = Settings.user.reset_password.update_reset_pass
redirect_to reset_password_final_path(token: @user.remember_token)
end
end
private
def find_token_param
return redirect_to reset_password_step1_path unless params[:token]
end
def forgot_pass_params
params.require(:user).permit( :password, :password_confirmation)
end
......
......@@ -10,7 +10,7 @@ class SessionsController < ApplicationController
sign_in user
redirect_to my_page_path
else
flash.now[:danger] = Settings.sign_in.sign_in_failed
flash.now[:danger] = Settings.user.sign_in.failed
render 'new'
end
end
......
......@@ -13,10 +13,6 @@ class Confirmation < ApplicationRecord
Digest::SHA1.hexdigest(token.to_s)
end
def token_expired?
updated_at <= 24.hours.ago
end
private
def create_confirm_token
......
......@@ -28,10 +28,10 @@ Rails.application.routes.draw do
get 'jobs/company/:converted_name', to: 'jobs#company_jobs', as: :company_jobs
resources :reset_passwords, only: [:edit, :update]
resources :confirmations
resources :top_pages
resources :industries
resources :cities
resources :confirmations, only: [:new]
resources :top_pages, only: [:index]
resources :industries, only: [:index]
resources :cities, only: [:index]
root to: "top_pages#index"
end
......
......@@ -6,15 +6,15 @@ user:
password_mismatch: 'Password is mismatch'
warning_signin: 'Please Sign In...'
reset_password:
sending_email_failed: 'Your Email invalid or not register'
sending_email_success: 'Please check your email to change your password'
reset_password:
failed: 'Your Email invalid or not register'
success: 'Please check your email to change your password'
update_reset_pass: 'Password or Password Confirmation is mismatch'
sign_in:
sign_in_failed: 'Invalid email or password'
sign_in:
failed: 'Invalid email or password'
sign_up:
email_existed: 'Email existed. Please change !!!'
email_format_failed: 'Email formated invalid'
sign_up:
existed: 'Email existed. Please change !!!'
format_failed: 'Email formated invalid'
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