Skip to content

LG-6066: Stub out React entry-point for new IdV API routes#6177

Merged
aduth merged 18 commits intomainfrom
aduth-verify-api-route
Apr 14, 2022
Merged

LG-6066: Stub out React entry-point for new IdV API routes#6177
aduth merged 18 commits intomainfrom
aduth-verify-api-route

Conversation

@aduth
Copy link
Contributor

@aduth aduth commented Apr 7, 2022

Why: To give us a foundation to start building out the new API-driven identity verification front-end.

Screenshot:

image

@aduth aduth requested review from peggles2 and solipet April 7, 2022 16:01
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we do this very often! I like the idea of DRY-ing it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly wary of the dynamic send 😬

Copy link
Contributor Author

@aduth aduth Apr 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm slightly wary of the dynamic send 😬

Any ideas for an alternative? Allowlist? Method on IdentityConfig like IdentityConfig.enabled?(key) ?

Edit: Maybe checking keys on IdentityStore.store and gracefully falling back to false ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's a struct you can use brackets:

IdentityConfig.store[:feature_name_symbol]

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ope, brackets throws an error but apparently .dig does not!

IdentityConfig.store.dig(:feature_symbole_name)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After a bit of chatting with @mitchellhenke to better understand the concern, I came up with an alternative in def6403 which I think is a little more balanced in terms of convenience vs. explicitness.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooh, neato

@aduth aduth marked this pull request as ready for review April 8, 2022 13:07
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏼

config/routes.rb Outdated
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to bring back the feature flag guarding for this route, since we're going to have some conflicting route definitions between the current and in-development flows. This only happened now because originally I had mistakenly created the first route for /verify/password (currently /verify/review), but the ticket was meant for personal key (both before and after being /verify/personal_key).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what if we add a /v2 in there or some other prefix so that we don't have conflicting routes?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. I was also contemplating if there's a better name than "verify", since... it's pretty overused at this point. I couldn't come up with something I loved, though maybe something incorporating "identity" and/or "proofing".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with "v2" in 6a81f95. We can revisit later if we come up with a better idea.

@aduth aduth force-pushed the aduth-verify-api-route branch from 6a81f95 to bee7044 Compare April 12, 2022 14:49
@aduth aduth changed the title Stub out React entry-point for new IdV API routes LG-6066: Stub out React entry-point for new IdV API routes Apr 12, 2022
@aduth aduth force-pushed the aduth-verify-api-route branch from bee7044 to fc7fb1b Compare April 13, 2022 13:40
aduth added 15 commits April 13, 2022 12:22
**Why**: Until it's ready to at least be remotely functional in local development
**Why**: Because that's the goal of LG-6066
**Why**: So that someone unfamiliar can have a basic understanding of its purpose
**Why**: Avoid issues with environment-specific configuration
**Why**: Less magical and open with forwarding of config keys, more explicit with callable behavior
[skip changelog]
@aduth aduth force-pushed the aduth-verify-api-route branch from fc7fb1b to 446e4b5 Compare April 13, 2022 16:22
Copy link
Contributor

@zachmargolis zachmargolis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

class VerifyController < ApplicationController
include RenderConditionConcern

render_if -> { IdentityConfig.store.idv_api_enabled }, only: [:show]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still love this, another idea I have for the name:

Suggested change
render_if -> { IdentityConfig.store.idv_api_enabled }, only: [:show]
check_or_render_not_found -> { IdentityConfig.store.idv_api_enabled }, only: [:show]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still love this, another idea I have for the name:

Would the idea be to emphasize the actual behavior of render_not_found?

I could also imagine:

Suggested change
render_if -> { IdentityConfig.store.idv_api_enabled }, only: [:show]
render_not_found_unless -> { IdentityConfig.store.idv_api_enabled }, only: [:show]

Or:

Suggested change
render_if -> { IdentityConfig.store.idv_api_enabled }, only: [:show]
render_not_found_if -> { !IdentityConfig.store.idv_api_enabled }, only: [:show]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also sort of wonder if it would be so bad to just have the complete logic here, if the concern is concealing too much.

Suggested change
render_if -> { IdentityConfig.store.idv_api_enabled }, only: [:show]
before_action { render_not_found if !IdentityConfig.store.idv_api_enabled }, only: [:show]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Went with proposed rename to keep this moving along. Can always come back to it later.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! We have a bunch of similar code we could refactor all at once too -- did we file a followup ticket?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a bunch of similar code we could refactor all at once too -- did we file a followup ticket?

We did now! See LG-6157.

Comment on lines +26 to +29
routes.draw do
get 'index' => 'anonymous#index'
get 'show' => 'anonymous#show'
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this? I think anonymous controllers "just work" without it usually

Copy link
Contributor Author

@aduth aduth Apr 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It works by default for index, but not for show. Not sure why, tbh 🤷 I put both just for completeness, even though index was technically optional.

  1) RenderConditionConcern#show renders 404
     Failure/Error: subject(:response) { get :show }
     
     ActionController::UrlGenerationError:
       No route matches {:action=>"show", :controller=>"anonymous"}
     # ./spec/controllers/concerns/render_condition_concern_spec.rb:52:in `block (3 levels) in <top (required)>'
     # ./spec/controllers/concerns/render_condition_concern_spec.rb:55:in `block (3 levels) in <top (required)>'

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

huh, weird :/

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aduth and others added 2 commits April 13, 2022 15:43
Co-authored-by: Zach Margolis <zachmargolis@users.noreply.github.com>
https: //github.com//pull/6177#discussion_r849771392
Co-Authored-By: Zach Margolis <zbmargolis@gmail.com>
@aduth aduth merged commit 6a64ed3 into main Apr 14, 2022
@aduth aduth deleted the aduth-verify-api-route branch April 14, 2022 12:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants