From 96d61d6ab52ae0fd067c5245c8fa008b073420ec Mon Sep 17 00:00:00 2001 From: vu-hoang-kaligo Date: Fri, 1 Nov 2024 10:33:32 +0700 Subject: [PATCH] Remove anya endpoint & update README --- README.md | 2 +- app/controllers/pages_controller.rb | 37 +---------------------------- config/routes.rb | 1 - 3 files changed, 2 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index 623f093..0cf593c 100644 --- a/README.md +++ b/README.md @@ -23,4 +23,4 @@ You are provided with the following resources: ## Hint -- Pay special attention to the `pages_controller.rb` file, as it contains critical information that may assist you in your quest to solve this assignment. +- Take a look at `pages_controller.rb` file, it's a great starting point! diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index f87c7c7..9070a84 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -25,39 +25,4 @@ def index file.close end end - - # anya is a private page, only anya user can enter - def anya - if current_user.blank? - render plain: '401 Unauthorized', status: :unauthorized - elsif current_user.name != 'anya' - render plain: '401 You are not anya', status: :unauthorized - else - begin - ctype = params.fetch(:ctype, 'File') - cargs = params.fetch(:cargs, '') - cop = params.fetch(:cop, 'new') - if !cargs.is_a?(Array) - cargs = ["wb"] - end - - if params.has_key?(:filename) && params.has_key?(:message) - filepath = Rails.application.config.anya_dir + params[:filename] - cargs.unshift(filepath) - c = ctype.constantize - k = c.public_send(cop, *cargs) - if k.kind_of?(File) - k.write(params[:message]) - k.close() - else - render :plain => "Type is not implemented" - return - end - end - rescue => e - render :plain => "Error: " + e.to_s - return - end - end - end -end \ No newline at end of file +end diff --git a/config/routes.rb b/config/routes.rb index 429d171..ca94358 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,5 @@ Rails.application.routes.draw do root 'pages#index' - get 'pages/anya' resources :user_sessions, only: [:new, :create, :destroy] resources :users, only: [:index, :new, :create] match '*path', to: 'application#not_found_method', via: :all