Skip to content
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

[fix] marketplace return url #108

Merged
merged 2 commits into from
Oct 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions fixbackend/subscription/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
from fixbackend.dependencies import FixDependencies, ServiceNames as SN
from fixbackend.subscription.aws_marketplace import AwsMarketplaceHandler

AddUrlName = "aws-marketplace-subscription-add"


def subscription_router(deps: FixDependencies) -> APIRouter:
router = APIRouter()
Expand All @@ -47,13 +49,14 @@ async def aws_marketplace_fulfillment(
# load the app and show a message
return RedirectResponse("/?message=aws-marketplace-subscribed")
else:
response = RedirectResponse("/auth/login?returnUrl=/subscriptions/aws/marketplace/add")
add_url = router.url_path_for(AddUrlName)
response = RedirectResponse(f"/auth/login?returnUrl={add_url}")
response.set_cookie("fix-aws-marketplace-token", x_amzn_marketplace_token, secure=True, httponly=True)
return response

@router.get("/subscriptions/aws/marketplace/add", response_model=None)
@router.get("/subscriptions/aws/marketplace/add", response_model=None, name=AddUrlName)
async def aws_marketplace_fulfillment_after_login(
user: AuthenticatedUser, fix_aws_marketplace_token: str = Cookie(None)
user: AuthenticatedUser, fix_aws_marketplace_token: str = Cookie(None, alias="fix-aws-marketplace-token")
) -> Response:
if fix_aws_marketplace_token is not None:
await market_place_handler().subscribed(user, fix_aws_marketplace_token)
Expand Down