-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generate a login link when running the demo mode CLI #30
Conversation
rzane
commented
Jul 23, 2024
def session_url(session) | ||
routes = DemoMode::Engine.routes | ||
|
||
options = routes.default_url_options.presence | ||
options ||= ActionMailer::Base.default_url_options.presence if defined?(ActionMailer::Base) | ||
options ||= { only_path: true } | ||
|
||
routes.url_for(controller: 'demo_mode/sessions', action: 'show', id: session, **options) | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a best effort approach. We try to resolve the URL in the following order:
- You can explicitly configure URL generation by setting
DemoMode::Engine.routes.default_url_options
. - We'll fallback to the
default_url_options
you've used forconfig.action_mailer.default_url_options
. This should work well for the majority of applications and custom configuration probably won't be necessary. - We'll fallback to generating just a path.
def email | ||
'[email protected]' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DemoMode CLI expects the signinable
to have an email, but the DummyUser
in our test personas doesn't actually have an email attribute.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
domain LGTM && platform LGTM! Love this feature. 👏