songtianlun
8bb7615cb1
- Change `user.send(:activate)` to `user.activate` for clarity. - Fix typo in email parameter from `emial` to `email` in password reset. - Update render calls to include status codes for better error handling. - Modify password reset email method to accept a user parameter. - Update tests to reflect changes in password reset functionality. These changes improve the clarity of the user activation process and ensure that the password reset functionality works correctly with proper error handling and user feedback.
16 lines
432 B
Ruby
16 lines
432 B
Ruby
class AccountActivationsController < ApplicationController
|
|
include SessionsHelper
|
|
def edit
|
|
user = User.find_by(email: params[:email])
|
|
if user && !user.activated? && user.authenticated?(:activation, params[:id])
|
|
user.activate
|
|
log_in user
|
|
flash[:success] = "Account activated!"
|
|
redirect_to user
|
|
else
|
|
flash[:danger] = "Invalid activation link"
|
|
redirect_to root_url
|
|
end
|
|
end
|
|
end
|