Fix logic update form

parent aaab73c8
Pipeline #920 failed with stages
in 0 seconds
class UsersController < ApplicationController class UsersController < ApplicationController
before_action :signed_in_user, only: [:update, :my_page, :my_info] before_action :sign_in_validation, only: [:update, :my_page, :my_info]
def my_page def my_page
end end
...@@ -7,7 +7,7 @@ class UsersController < ApplicationController ...@@ -7,7 +7,7 @@ class UsersController < ApplicationController
end end
def update def update
user_params[:password] = current_user.password_digest if user_params[:password].nil? user_params[:password] = current_user.password_digest if user_params[:password].blank?
if BCrypt::Password.new(current_user.password_digest) != condition_update[:oldpassword] if BCrypt::Password.new(current_user.password_digest) != condition_update[:oldpassword]
flash.now[:danger] = 'Old Password is mismatch' flash.now[:danger] = 'Old Password is mismatch'
else else
...@@ -24,11 +24,14 @@ class UsersController < ApplicationController ...@@ -24,11 +24,14 @@ class UsersController < ApplicationController
private private
def signed_in_user def validate_oldpass
unless signed_in?
flash[:warning] = "Please Sign In..." end
redirect_to login_path
end def sign_in_validation
return if signed_in?
flash[:warning] = "Please Sign In..."
redirect_to login_path
end end
def user_params def user_params
......
...@@ -19,7 +19,7 @@ class User < ApplicationRecord ...@@ -19,7 +19,7 @@ class User < ApplicationRecord
validates :password, allow_nil: true, length: { minimum: 6, too_short: "is blank or too short" } validates :password, allow_nil: true, length: { minimum: 6, too_short: "is blank or too short" }
def User.new_remember_token def self.new_remember_token
SecureRandom.urlsafe_base64 SecureRandom.urlsafe_base64
end end
......
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