From 0b9f965a7e2fd8f72ff777eaacefc78dca53d3eb Mon Sep 17 00:00:00 2001 From: Pete Cheslock Date: Fri, 22 Dec 2023 11:17:47 -0500 Subject: [PATCH] Create an option to only allow users to edit their profile within 24 hours of creation --- app/controllers/users_controller.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index 9f74f4f..3ca3c01 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -74,7 +74,9 @@ def user_params # Confirms the correct user. def correct_user @user = User.find(params[:id]) - redirect_to(root_url, status: :see_other) unless current_user?(@user) + if Time.now - @user.created_at > 24.hours + flash[:danger] = "You can only edit your profile within 24 hours of account creation." + end end # Confirms an admin user.