-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implemented dashboard and rpc controller
- Loading branch information
1 parent
e3b906d
commit 842ed1f
Showing
18 changed files
with
386 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,4 +84,6 @@ group :development do | |
gem 'annotate' | ||
end | ||
|
||
gem "discard" | ||
gem "discard" | ||
|
||
gem "jwt" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
# frozen_string_literal: true | ||
|
||
class DashboardController < ApplicationController | ||
def show | ||
respond_to do |format| | ||
format.html | ||
before_action :validate_presence_of_jwt_token! | ||
before_action :authenticate_via_jwt! | ||
|
||
def index | ||
unless @current_acccount | ||
logger.info "[401 Unauthorized] #{@error}" | ||
render_401 and return | ||
end | ||
|
||
@endpoint = @current_acccount.endpoints.kept | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,25 @@ | ||
# frozen_string_literal: true | ||
|
||
class RPCController < ApplicationController | ||
def rpc; end | ||
before_action :validate_headers | ||
|
||
RPC_METHODS = %w[qn_hello_world].freeze | ||
|
||
def rpc | ||
@account = Account.kept.find_by(quicknode_id: request.headers["X-QUICKNODE-ID"]) | ||
render_404 and return unless @account.present? | ||
|
||
render_404 and return unless RPC_METHODS.include?(params[:method]) | ||
|
||
render json: { jsonrpc: "2.0", result: "hello world" } | ||
end | ||
|
||
private | ||
|
||
def validate_headers # rubocop:disable Metrics/CyclomaticComplexity | ||
render_400 and return unless request.headers["X-QUICKNODE-ID"].present? | ||
render_400 and return unless request.headers["X-INSTANCE-ID"].present? | ||
render_400 and return unless request.headers["X-QN-CHAIN"].present? | ||
render_400 and return unless request.headers["X-QN-NETWORK"].present? | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>Dashboard</h1> | ||
|
||
<%= session[:name] %> | ||
<%= session[:email] %> | ||
<%= session[:organization_name] %> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
aTPehLiCrSJ0I7BwkJ6q/zX+M+lg34DcaNO4qvWUtg7hKDnGxIwo3xwCnHWWobKmoISPBVAm1v8amIQxUBi7+Sb2uIXcb8OoO9HwULDW6LBDvXrjncbDS4J2tmHUlkCFr+ENQpMPjOth9msJYmUm7MgWM0TLowNSFD7oVS0QdDXMkrvmjKVDpVjAQziLUCEZmbWTiDkhSgAgjxvxDbHxk+7XIkKiQVTepindc6e3cXOviVB7O49f/p/cHaIwsEkjxD7XpHGNa8bDdbSPqQf7JFbP+Yi5AwE+wu7Sw3oWTd4bWOtEYm/8AEBBmjYieeh+PPPsnXwrRVtTGAHp/CPi6VfvJhU1jNSODQXEmdtFt7avgQfjn1yjZ9c7nj8XmJXo66tycV56VjJMZ1SndiA=--Fxhv/oUs/THaAbR8--tbwfBVPso0I6FZHZb5K6IQ== | ||
yiQVMZFkaATpdGSSl2kUoXV1hl8UQItLV2LawNnnlpvooJz9n2FasjKQSvO6xvmEgfy8DQ9Tt9WODHB+fCIMCqKY1kWS4cMVb6s3orYA3t08O7lNzGN0p3iPlI564m1ITu7jJ/k31SLmJAiRdfelLsgjhP6BrTaFUuqnyxuKkd4QVsZc0cVQfu5QvMyoKrIfTyY/lMvjtj6pcI+5laerCsI1U3AQuadTuXx1/Csz2fqLnWITEPz0b6X8SoPWvEoHAvVyT+u6Qf/Wm6VmSKqu5oRqota0MqBoyx5vMQsIQ/y5UChn3pCz5XnwZOdSYxj36PpzyZ6PGvgf9AGhsCDA7BtcADd8Ia6bWkwFSTaNWnCk1XzE5eCvC5O705N9EyOJtxJdmd656H5QV+MNkmv1jQ8iLLIgqKddj/KWwhzmawP3IDq7fJalpzk=--tVJ/MS2Xvc39LbvV--LAAV2BfvBCnFIsPfb4Ztbg== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Bad Request (400)</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<style> | ||
.rails-default-error-page { | ||
background-color: #EFEFEF; | ||
color: #2E2F30; | ||
text-align: center; | ||
font-family: arial, sans-serif; | ||
margin: 0; | ||
} | ||
|
||
.rails-default-error-page div.dialog { | ||
width: 95%; | ||
max-width: 33em; | ||
margin: 4em auto 0; | ||
} | ||
|
||
.rails-default-error-page div.dialog > div { | ||
border: 1px solid #CCC; | ||
border-right-color: #999; | ||
border-left-color: #999; | ||
border-bottom-color: #BBB; | ||
border-top: #B00100 solid 4px; | ||
border-top-left-radius: 9px; | ||
border-top-right-radius: 9px; | ||
background-color: white; | ||
padding: 7px 12% 0; | ||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); | ||
} | ||
|
||
.rails-default-error-page h1 { | ||
font-size: 100%; | ||
color: #730E15; | ||
line-height: 1.5em; | ||
} | ||
|
||
.rails-default-error-page div.dialog > p { | ||
margin: 0 0 1em; | ||
padding: 1em; | ||
background-color: #F7F7F7; | ||
border: 1px solid #CCC; | ||
border-right-color: #999; | ||
border-left-color: #999; | ||
border-bottom-color: #999; | ||
border-bottom-left-radius: 4px; | ||
border-bottom-right-radius: 4px; | ||
border-top-color: #DADADA; | ||
color: #666; | ||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body class="rails-default-error-page"> | ||
<!-- This file lives in public/400.html --> | ||
<div class="dialog"> | ||
<div> | ||
<h1>Bad Request</h1> | ||
<p>The request is not valid.</p> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>Unauthorized (401)</title> | ||
<meta name="viewport" content="width=device-width,initial-scale=1"> | ||
<style> | ||
.rails-default-error-page { | ||
background-color: #EFEFEF; | ||
color: #2E2F30; | ||
text-align: center; | ||
font-family: arial, sans-serif; | ||
margin: 0; | ||
} | ||
|
||
.rails-default-error-page div.dialog { | ||
width: 95%; | ||
max-width: 33em; | ||
margin: 4em auto 0; | ||
} | ||
|
||
.rails-default-error-page div.dialog > div { | ||
border: 1px solid #CCC; | ||
border-right-color: #999; | ||
border-left-color: #999; | ||
border-bottom-color: #BBB; | ||
border-top: #B00100 solid 4px; | ||
border-top-left-radius: 9px; | ||
border-top-right-radius: 9px; | ||
background-color: white; | ||
padding: 7px 12% 0; | ||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); | ||
} | ||
|
||
.rails-default-error-page h1 { | ||
font-size: 100%; | ||
color: #730E15; | ||
line-height: 1.5em; | ||
} | ||
|
||
.rails-default-error-page div.dialog > p { | ||
margin: 0 0 1em; | ||
padding: 1em; | ||
background-color: #F7F7F7; | ||
border: 1px solid #CCC; | ||
border-right-color: #999; | ||
border-left-color: #999; | ||
border-bottom-color: #999; | ||
border-bottom-left-radius: 4px; | ||
border-bottom-right-radius: 4px; | ||
border-top-color: #DADADA; | ||
color: #666; | ||
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17); | ||
} | ||
</style> | ||
</head> | ||
|
||
<body class="rails-default-error-page"> | ||
<!-- This file lives in public/500.html --> | ||
<div class="dialog"> | ||
<div> | ||
<h1>Unauthorized.</h1> | ||
</div> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.