def confirm
      token = params[:token].to_s

      user = User.find_by(confirmation_token: token)

      if user.present? && user.confirmation_token_valid?
        if user.mark_as_confirmed!
          render json: {status: 'Account confirmed successfully.'}
        else
          render json: user.errors, status: 422
        end
      else
        render json: ['Invalid token'], status: :not_found
      end
    end
def confirm
      token = params[:token].to_s

      user = User.find_by(confirmation_token: token)

      if user.present? && user.confirmation_token_valid?
        if user.mark_as_confirmed!
          render json: {status: 'Account confirmed successfully.'}
        else
          render json: user.errors, status: 422
        end
      else
        render json: ['Invalid token'], status: :not_found
      end
    end
confirm user account