Skip to content

Commit

Permalink
Merge pull request #524 from hackforla/Cognito-redirect-URLs-configur…
Browse files Browse the repository at this point in the history
…able

Cognito redirect ur ls configurable
  • Loading branch information
stevbark authored Jun 21, 2023
2 parents 9070658 + 49b1594 commit fdf9f07
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
3 changes: 2 additions & 1 deletion api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ COGNITO_REDIRECT_URI=http://localhost:4040/signin
COGNITO_USER_POOL_ID=
SECRET_KEY=
COGNITO_ACCESS_ID=
COGNITO_ACCESS_KEY=
COGNITO_ACCESS_KEY=
ROOT_URL=http://localhost:4040
7 changes: 4 additions & 3 deletions api/openapi_server/controllers/auth_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
COGNITO_ACCESS_ID = env.get('COGNITO_ACCESS_ID')
COGNITO_ACCESS_KEY = env.get('COGNITO_ACCESS_KEY')
SECRET_KEY=env.get('SECRET_KEY')
ROOT_URL=env.get('ROOT_URL')
cognito_client_url = 'https://homeuniteus.auth.us-east-1.amazoncognito.com'


Expand Down Expand Up @@ -154,7 +155,7 @@ def signin():
if(response.get('ChallengeName') and response['ChallengeName'] == 'NEW_PASSWORD_REQUIRED'):
userId = response['ChallengeParameters']['USER_ID_FOR_SRP']
sessionId = response['Session']
return redirect(f"http://localhost:4040/create-password?userId={userId}&sessionId={sessionId}")
return redirect(f"{ROOT_URL}/create-password?userId={userId}&sessionId={sessionId}")

access_token = response['AuthenticationResult']['AccessToken']
refresh_token = response['AuthenticationResult']['RefreshToken']
Expand Down Expand Up @@ -423,9 +424,9 @@ def confirm_signup():
ConfirmationCode=code
)

return redirect("http://localhost:4040/email-verification-success")
return redirect(f"{ROOT_URL}/email-verification-success")
except Exception as e:
return redirect("http://localhost:4040/email-verification-error")
return redirect(f"{ROOT_URL}/email-verification-error")

# What comes first invite or adding the user
#Do I have an oauth token
Expand Down

0 comments on commit fdf9f07

Please sign in to comment.