Class: ShopifyCLI::IdentityAuth::Servlet
- Inherits:
-
WEBrick::HTTPServlet::AbstractServlet
- Object
- WEBrick::HTTPServlet::AbstractServlet
- ShopifyCLI::IdentityAuth::Servlet
- Defined in:
- lib/shopify_cli/identity_auth/servlet.rb
Constant Summary collapse
- ERB_FILENAME =
File.join(ROOT, "lib/shopify_cli/assets/post_auth_page/index.html.erb")
- CSS_FILENAME =
File.join(ROOT, "lib/shopify_cli/assets/post_auth_page/style.css")
Instance Method Summary collapse
-
#do_GET(req, res) ⇒ Object
rubocop:disable Naming/MethodName.
-
#initialize(server, identity_auth, token) ⇒ Servlet
constructor
A new instance of Servlet.
- #respond_with(response, status, message) ⇒ Object
Constructor Details
#initialize(server, identity_auth, token) ⇒ Servlet
Returns a new instance of Servlet.
7 8 9 10 11 12 |
# File 'lib/shopify_cli/identity_auth/servlet.rb', line 7 def initialize(server, identity_auth, token) super @server = server @identity_auth = identity_auth @state_token = token end |
Instance Method Details
#do_GET(req, res) ⇒ Object
rubocop:disable Naming/MethodName
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/shopify_cli/identity_auth/servlet.rb', line 14 def do_GET(req, res) # rubocop:disable Naming/MethodName if !req.query["error"].nil? respond_with( res, 400, Context.("core.identity_auth.servlet.invalid_request_response", req.query["error_description"]) ) elsif req.query["state"] != @state_token = Context.("core.identity_auth.servlet.invalid_state_response") req.query.merge!("error" => "invalid_state", "error_description" => ) respond_with(res, 403, ) else respond_with(res, 200, Context.("core.identity_auth.servlet.success_response")) end @identity_auth.response_query = req.query @server.shutdown end |
#respond_with(response, status, message) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/shopify_cli/identity_auth/servlet.rb', line 32 def respond_with(response, status, ) successful = status == 200 locals = { status: status, message: , css: File.read(CSS_FILENAME), } response.status = status response.body = ERB.new(File.read(ERB_FILENAME)).result(binding) end |