WIP 1
This commit is contained in:
parent
1acd3e30ae
commit
9058d1ae2e
11 changed files with 126 additions and 5 deletions
|
|
@ -41,6 +41,7 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="activesupport (v8.0.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="TEST" name="annotaterb (v4.22.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.3, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="backport (v1.2.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="base64 (v0.3.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="bcrypt (v3.1.21, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="bcrypt_pbkdf (v1.1.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -56,6 +57,7 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="crass (v1.0.6, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="date (v3.5.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="debug (v1.11.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.6.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="dotenv (v3.2.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="TEST" name="dotenv-rails (v3.2.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="drb (v2.2.3, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -68,8 +70,11 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="i18n (v1.14.8, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="io-console (v0.8.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="irb (v1.18.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="jaro_winkler (v1.6.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="json (v2.19.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="kamal (v2.11.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="kramdown (v2.5.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="kramdown-parser-gfm (v1.1.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="language_server-protocol (v3.17.0.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="lint_roller (v1.1.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="logger (v1.7.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -88,6 +93,7 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="net-ssh (v7.3.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="nio4r (v2.7.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.19.3, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="observer (v0.1.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="ostruct (v0.6.3, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="parallel (v2.1.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="parser (v3.3.11.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -110,9 +116,11 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="railties (v8.0.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rake (v13.4.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rbs (v3.9.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rdoc (v7.2.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.12.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="reline (v0.6.3, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="reverse_markdown (v3.0.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.4.4, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rubocop (v1.86.2, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.49.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -122,6 +130,7 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="ruby-graphviz (v1.2.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.13.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="securerandom (v0.4.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="TEST" name="solargraph (v0.57.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="solid_cable (v3.0.12, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="solid_cache (v1.0.10, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="solid_queue (v1.4.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -129,6 +138,7 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="stringio (v3.2.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="thor (v1.5.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="thruster (v0.1.20, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="tilt (v2.6.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="timeout (v0.6.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="tsort (v0.2.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.6, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
|
|
@ -138,6 +148,9 @@
|
|||
<orderEntry type="library" scope="PROVIDED" name="useragent (v0.16.11, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="websocket-driver (v0.8.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="websocket-extensions (v0.1.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="yard (v0.9.37, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="yard-activesupport-concern (v0.0.1, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="yard-solargraph (v0.1.0, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.7.5, RVM: ruby-3.4.4) [gem]" level="application" />
|
||||
</component>
|
||||
<component name="RModuleSettingsStorage">
|
||||
|
|
|
|||
5
Gemfile
5
Gemfile
|
|
@ -49,4 +49,7 @@ group :development, :test do
|
|||
|
||||
gem "annotaterb"
|
||||
gem "dotenv-rails"
|
||||
end
|
||||
|
||||
# Ruby language server for IDE support
|
||||
gem "solargraph", require: false
|
||||
end
|
||||
|
|
|
|||
40
Gemfile.lock
40
Gemfile.lock
|
|
@ -76,6 +76,7 @@ GEM
|
|||
activerecord (>= 6.0.0)
|
||||
activesupport (>= 6.0.0)
|
||||
ast (2.4.3)
|
||||
backport (1.2.0)
|
||||
base64 (0.3.0)
|
||||
bcrypt (3.1.21)
|
||||
bcrypt_pbkdf (1.1.2)
|
||||
|
|
@ -94,6 +95,7 @@ GEM
|
|||
debug (1.11.1)
|
||||
irb (~> 1.10)
|
||||
reline (>= 0.3.8)
|
||||
diff-lcs (1.6.2)
|
||||
dotenv (3.2.0)
|
||||
dotenv-rails (3.2.0)
|
||||
dotenv (= 3.2.0)
|
||||
|
|
@ -117,6 +119,7 @@ GEM
|
|||
prism (>= 1.3.0)
|
||||
rdoc (>= 4.0.0)
|
||||
reline (>= 0.4.2)
|
||||
jaro_winkler (1.6.1)
|
||||
json (2.19.5)
|
||||
kamal (2.11.0)
|
||||
activesupport (>= 7.0)
|
||||
|
|
@ -129,6 +132,10 @@ GEM
|
|||
sshkit (>= 1.23.0, < 2.0)
|
||||
thor (~> 1.3)
|
||||
zeitwerk (>= 2.6.18, < 3.0)
|
||||
kramdown (2.5.1)
|
||||
rexml (>= 3.3.9)
|
||||
kramdown-parser-gfm (1.1.0)
|
||||
kramdown (~> 2.0)
|
||||
language_server-protocol (3.17.0.5)
|
||||
lint_roller (1.1.0)
|
||||
logger (1.7.0)
|
||||
|
|
@ -176,6 +183,7 @@ GEM
|
|||
racc (~> 1.4)
|
||||
nokogiri (1.19.3-x86_64-linux-musl)
|
||||
racc (~> 1.4)
|
||||
observer (0.1.2)
|
||||
ostruct (0.6.3)
|
||||
parallel (2.1.0)
|
||||
parser (3.3.11.1)
|
||||
|
|
@ -243,6 +251,8 @@ GEM
|
|||
zeitwerk (~> 2.6)
|
||||
rainbow (3.1.1)
|
||||
rake (13.4.2)
|
||||
rbs (3.9.5)
|
||||
logger
|
||||
rdoc (7.2.0)
|
||||
erb
|
||||
psych (>= 4.0.0)
|
||||
|
|
@ -250,6 +260,8 @@ GEM
|
|||
regexp_parser (2.12.0)
|
||||
reline (0.6.3)
|
||||
io-console (~> 0.5)
|
||||
reverse_markdown (3.0.0)
|
||||
nokogiri
|
||||
rexml (3.4.4)
|
||||
rubocop (1.86.2)
|
||||
json (~> 2.3)
|
||||
|
|
@ -283,6 +295,27 @@ GEM
|
|||
rexml
|
||||
ruby-progressbar (1.13.0)
|
||||
securerandom (0.4.1)
|
||||
solargraph (0.57.0)
|
||||
backport (~> 1.2)
|
||||
benchmark (~> 0.4)
|
||||
bundler (~> 2.0)
|
||||
diff-lcs (~> 1.4)
|
||||
jaro_winkler (~> 1.6, >= 1.6.1)
|
||||
kramdown (~> 2.3)
|
||||
kramdown-parser-gfm (~> 1.1)
|
||||
logger (~> 1.6)
|
||||
observer (~> 0.1)
|
||||
ostruct (~> 0.6)
|
||||
parser (~> 3.0)
|
||||
prism (~> 1.4)
|
||||
rbs (>= 3.6.1, <= 4.0.0.dev.4)
|
||||
reverse_markdown (~> 3.0)
|
||||
rubocop (~> 1.76)
|
||||
thor (~> 1.0)
|
||||
tilt (~> 2.0)
|
||||
yard (~> 0.9, >= 0.9.24)
|
||||
yard-activesupport-concern (~> 0.0)
|
||||
yard-solargraph (~> 0.1)
|
||||
solid_cable (3.0.12)
|
||||
actioncable (>= 7.2)
|
||||
activejob (>= 7.2)
|
||||
|
|
@ -312,6 +345,7 @@ GEM
|
|||
thruster (0.1.20-aarch64-linux)
|
||||
thruster (0.1.20-arm64-darwin)
|
||||
thruster (0.1.20-x86_64-linux)
|
||||
tilt (2.6.1)
|
||||
timeout (0.6.1)
|
||||
tsort (0.2.0)
|
||||
tzinfo (2.0.6)
|
||||
|
|
@ -325,6 +359,11 @@ GEM
|
|||
base64
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.5)
|
||||
yard (0.9.37)
|
||||
yard-activesupport-concern (0.0.1)
|
||||
yard (>= 0.8)
|
||||
yard-solargraph (0.1.0)
|
||||
yard (~> 0.9)
|
||||
zeitwerk (2.7.5)
|
||||
|
||||
PLATFORMS
|
||||
|
|
@ -351,6 +390,7 @@ DEPENDENCIES
|
|||
rails (~> 8.0.4)
|
||||
rails-erd
|
||||
rubocop-rails-omakase
|
||||
solargraph
|
||||
solid_cable
|
||||
solid_cache
|
||||
solid_queue
|
||||
|
|
|
|||
|
|
@ -1,12 +1,15 @@
|
|||
class ApplicationController < ActionController::API
|
||||
module ApplicationController
|
||||
extend ActionController::API
|
||||
before_action :authenticate!
|
||||
|
||||
rescue_from Unauthorized, with: -> { render json: { error: "Unauthorized" }, status: :unauthorized }
|
||||
|
||||
private
|
||||
def authenticate!
|
||||
token = request.headers["Authorization"]&.split(" ")&.last
|
||||
@current_user = User.find_by(token:)
|
||||
|
||||
render json: { error: "Unauthorized" }, status: :unauthorized unless @current_user
|
||||
@current_user = Session.find_by(token:)&.user
|
||||
|
||||
raise Unauthorized unless @current_user
|
||||
end
|
||||
|
||||
def current_user
|
||||
|
|
|
|||
17
app/controllers/concerns/renderable.rb
Normal file
17
app/controllers/concerns/renderable.rb
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Renderable
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def render_success(data = nil, status = :ok, meta = {})
|
||||
body = { success: true }
|
||||
body[:data] = data if data
|
||||
body[:meta] = meta if meta.present?
|
||||
render json: body
|
||||
end
|
||||
|
||||
def render_error
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
12
app/controllers/sessions_controller.rb
Normal file
12
app/controllers/sessions_controller.rb
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
class SessionsController < ApplicationController
|
||||
before_action :authenticate_user, only: [:destroy]
|
||||
|
||||
def create
|
||||
user = User.find_by(email: params[:email])
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
end
|
||||
end
|
||||
13
app/controllers/users_controller.rb
Normal file
13
app/controllers/users_controller.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class UsersController < ApplicationController
|
||||
def create
|
||||
|
||||
end
|
||||
|
||||
def show
|
||||
|
||||
end
|
||||
|
||||
def destroy
|
||||
|
||||
end
|
||||
end
|
||||
1
app/errors/unauthorized.rb
Normal file
1
app/errors/unauthorized.rb
Normal file
|
|
@ -0,0 +1 @@
|
|||
class Unauthorized < StandardError; end
|
||||
|
|
@ -6,6 +6,11 @@ Rails.application.routes.draw do
|
|||
resources :products do
|
||||
resources :price_reports, only: [:index, :create]
|
||||
end
|
||||
|
||||
post 'login', to: 'sessions#create'
|
||||
delete 'logout', to: 'sessions#destroy'
|
||||
post 'signup', to: 'users#create'
|
||||
|
||||
# Define your application routes per the DSL in https://guides.rubyonrails.org/routing.html
|
||||
|
||||
# Reveal health status on /up that returns 200 if the app boots with no exceptions, otherwise 500.
|
||||
|
|
|
|||
7
test/controllers/sessions_controller_test.rb
Normal file
7
test/controllers/sessions_controller_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
7
test/controllers/users_controller_test.rb
Normal file
7
test/controllers/users_controller_test.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
require "test_helper"
|
||||
|
||||
class UsersControllerTest < ActionDispatch::IntegrationTest
|
||||
# test "the truth" do
|
||||
# assert true
|
||||
# end
|
||||
end
|
||||
Loading…
Reference in a new issue