summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHombreLaser <sebastian-440@live.com>2023-03-03 21:25:38 -0600
committerHombreLaser <sebastian-440@live.com>2023-03-03 21:25:38 -0600
commit33230f933454e64436dddb906d53512f97a60ce1 (patch)
treea1537b02ecba32d0ce40c8e451ea870439e9520c
parent898d91cca5721db785e991e0eab9f05010925b1a (diff)
Arregla algunos métodos de controladores
-rw-r--r--app/controllers/api/sessions_controller.rb6
-rw-r--r--app/controllers/api/user_accounts_controller.rb2
-rw-r--r--config/routes.rb2
3 files changed, 6 insertions, 4 deletions
diff --git a/app/controllers/api/sessions_controller.rb b/app/controllers/api/sessions_controller.rb
index 9d0e4ac..64d5464 100644
--- a/app/controllers/api/sessions_controller.rb
+++ b/app/controllers/api/sessions_controller.rb
@@ -2,7 +2,9 @@
module Api
# The controller that handles authentications.
- class SessionsController < ApplicationController
+ class SessionsController < AuthenticatedController
+ skip_before_action :validate_jwt, only: [:create]
+
def create
@user_account = UserAccount.find_by(email: permitted_params[:email])
@@ -14,7 +16,7 @@ module Api
end
def destroy
- user_account.update_attribute(:session_key, nil)
+ current_user_account.update_attribute(:session_key, nil)
render status: :no_content
end
diff --git a/app/controllers/api/user_accounts_controller.rb b/app/controllers/api/user_accounts_controller.rb
index ca5d93b..85323df 100644
--- a/app/controllers/api/user_accounts_controller.rb
+++ b/app/controllers/api/user_accounts_controller.rb
@@ -6,7 +6,7 @@ module Api
skip_before_action :validate_jwt, only: [:create]
def show
- render json: serialized_user_account.serializable_hash
+ render json: Serializers::UserAccountSerializer.new(current_user_account).serializable_hash
end
def create
diff --git a/config/routes.rb b/config/routes.rb
index b3b67a8..1728bcc 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -8,7 +8,7 @@ Rails.application.routes.draw do
namespace :api do
post '/login', to: 'sessions#create'
delete '/logout', to: 'sessions#destroy'
- get '/user_account', to: 'user_accounts#show'
+ get '/account', to: 'user_accounts#show'
resources :user_accounts, only: %i[create]
resources :refresh_tokens, only: %i[create]
end