-
Notifications
You must be signed in to change notification settings - Fork 79
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 for google sign in issue #1600
Open
GMayank0310
wants to merge
2
commits into
digiteinfotech:master
Choose a base branch
from
GMayank0310:fix_for_google_sign_in_issue
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ | |
from rasa.shared.utils.io import read_config_file | ||
from slack_sdk.web.slack_response import SlackResponse | ||
|
||
from kairon.shared.account.data_objects import UserEmailConfirmation | ||
from kairon.shared.actions.models import ActionParameterType, DbActionOperationType, DbQueryValueType | ||
from kairon.shared.admin.data_objects import LLMSecret | ||
from kairon.shared.callback.data_objects import CallbackLog, CallbackRecordStatusType | ||
|
@@ -28591,6 +28592,7 @@ def _password_reset(*args, **kwargs): | |
data={"username": "[email protected]", "password": "Welcome@10"}, | ||
) | ||
actual = response_log.json() | ||
UserEmailConfirmation(email="[email protected]").save() | ||
|
||
assert actual["success"] | ||
assert actual["error_code"] == 0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,7 +28,8 @@ | |
from kairon.exceptions import AppException | ||
from kairon.idp.data_objects import IdpConfig | ||
from kairon.idp.processor import IDPProcessor | ||
from kairon.shared.account.data_objects import Feedback, BotAccess, User, Bot, Account, Organization, TrustedDevice | ||
from kairon.shared.account.data_objects import Feedback, BotAccess, User, Bot, Account, Organization, TrustedDevice, \ | ||
UserEmailConfirmation | ||
from kairon.shared.account.processor import AccountProcessor | ||
from kairon.shared.admin.data_objects import BotSecrets | ||
from kairon.shared.auth import Authentication, LoginSSOFactory | ||
|
@@ -479,6 +480,8 @@ def test_delete_account_for_account_bots(self): | |
"last_name": "Test_Delete_Last", | ||
"password": SecretStr("Welcome@1"), | ||
} | ||
email=account.get('email') | ||
UserEmailConfirmation(email=email).save() | ||
|
||
loop = asyncio.new_event_loop() | ||
user_detail, mail, link = loop.run_until_complete(AccountProcessor.account_setup(account_setup=account)) | ||
|
@@ -489,11 +492,13 @@ def test_delete_account_for_account_bots(self): | |
account_bots_before_delete = list(AccountProcessor.list_bots(pytest.deleted_account)) | ||
|
||
assert len(account_bots_before_delete) == 2 | ||
AccountProcessor.delete_account(pytest.deleted_account) | ||
AccountProcessor.delete_account(pytest.deleted_account, email) | ||
|
||
for bot in account_bots_before_delete: | ||
with pytest.raises(DoesNotExist): | ||
Bot.objects(id=bot['_id'], account=pytest.deleted_account, status=True).get() | ||
with pytest.raises(DoesNotExist): | ||
UserEmailConfirmation.objects(email=email).get() | ||
|
||
def test_delete_account_for_shared_bot(self): | ||
account = { | ||
|
@@ -508,6 +513,8 @@ def test_delete_account_for_shared_bot(self): | |
user_detail, mail, link = loop.run_until_complete( | ||
AccountProcessor.account_setup(account_setup=account)) | ||
|
||
email=account.get('email') | ||
UserEmailConfirmation(email=email).save() | ||
# Add shared bot | ||
bot_response = AccountProcessor.add_bot("delete_account_shared_bot", user_detail['account'], "[email protected]", False) | ||
bot_id = bot_response['_id'].__str__() | ||
|
@@ -519,11 +526,15 @@ def test_delete_account_for_shared_bot(self): | |
assert len(accessors_before_delete) == 2 | ||
assert accessors_before_delete[0]['accessor_email'] == '[email protected]' | ||
assert accessors_before_delete[1]['accessor_email'] == '[email protected]' | ||
AccountProcessor.delete_account(pytest.deleted_account) | ||
AccountProcessor.delete_account(pytest.deleted_account, email) | ||
accessors_after_delete = list(AccountProcessor.list_bot_accessors(bot_id)) | ||
assert len(accessors_after_delete) == 0 | ||
assert len(list(Bot.objects(id=bot_id, account=user_detail['account'], status=True))) == 0 | ||
|
||
with pytest.raises(DoesNotExist): | ||
UserEmailConfirmation.objects(email=email).get() | ||
|
||
|
||
def test_delete_account_for_account(self): | ||
account = { | ||
"account": "Test_Delete_Account", | ||
|
@@ -532,18 +543,23 @@ def test_delete_account_for_account(self): | |
"last_name": "Test_Delete_Last", | ||
"password": SecretStr("Welcome@1") | ||
} | ||
email=account.get('email') | ||
UserEmailConfirmation(email=email).save() | ||
|
||
loop = asyncio.new_event_loop() | ||
user_detail, mail, link = loop.run_until_complete( | ||
AccountProcessor.account_setup(account_setup=account)) | ||
pytest.deleted_account = user_detail['account'].__str__() | ||
|
||
AccountProcessor.delete_account(pytest.deleted_account) | ||
AccountProcessor.delete_account(pytest.deleted_account, email) | ||
assert AccountProcessor.get_account(pytest.deleted_account) | ||
assert not AccountProcessor.get_account(pytest.deleted_account).get('status') | ||
|
||
with pytest.raises(AppException, match="Account does not exist!"): | ||
AccountProcessor.delete_account(pytest.deleted_account) | ||
AccountProcessor.delete_account(pytest.deleted_account, email) | ||
|
||
with pytest.raises(DoesNotExist): | ||
UserEmailConfirmation.objects(email=email).get() | ||
|
||
def test_delete_account_for_user(self): | ||
account = { | ||
|
@@ -553,6 +569,8 @@ def test_delete_account_for_user(self): | |
"last_name": "Test_Delete_Last", | ||
"password": SecretStr("Welcome@1") | ||
} | ||
email=account.get('email') | ||
UserEmailConfirmation(email=email).save() | ||
|
||
loop = asyncio.new_event_loop() | ||
user_detail, mail, link = loop.run_until_complete( | ||
|
@@ -573,11 +591,14 @@ def test_delete_account_for_user(self): | |
assert User.objects(email__iexact="[email protected]", status=True).get() | ||
assert User.objects(email__iexact="[email protected]", status=True).get() | ||
|
||
AccountProcessor.delete_account(pytest.deleted_account) | ||
AccountProcessor.delete_account(pytest.deleted_account, email) | ||
|
||
assert User.objects(email__iexact="[email protected]", status=False) | ||
assert User.objects(email__iexact="[email protected]", status=False) | ||
|
||
with pytest.raises(DoesNotExist): | ||
UserEmailConfirmation.objects(email=email).get() | ||
|
||
def test_delete_account_again_add(self): | ||
account = { | ||
"account": "Test_Delete_Account", | ||
|
@@ -586,19 +607,23 @@ def test_delete_account_again_add(self): | |
"last_name": "Test_Delete_Last", | ||
"password": SecretStr("Welcome@1"), | ||
} | ||
|
||
email=account.get('email') | ||
UserEmailConfirmation(email=email).save() | ||
loop = asyncio.new_event_loop() | ||
user_detail, mail, link = loop.run_until_complete( | ||
AccountProcessor.account_setup(account_setup=account)) | ||
pytest.deleted_account = user_detail['account'].__str__() | ||
|
||
AccountProcessor.delete_account(pytest.deleted_account) | ||
AccountProcessor.delete_account(pytest.deleted_account, email) | ||
|
||
loop = asyncio.new_event_loop() | ||
user_detail, mail, link = loop.run_until_complete( | ||
AccountProcessor.account_setup(account_setup=account)) | ||
new_account_id = user_detail['account'].__str__() | ||
|
||
with pytest.raises(DoesNotExist): | ||
UserEmailConfirmation.objects(email=email).get() | ||
|
||
assert new_account_id | ||
assert AccountProcessor.get_account(new_account_id).get('status') | ||
assert len(list(AccountProcessor.list_bots(new_account_id))) == 0 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Add error handling and fix indentation for UserEmailConfirmation deletion
The deletion of UserEmailConfirmation records needs improvement:
Apply this diff to implement the suggested changes:
Also, consider moving this block right after the account validation and before bot deletion for better cleanup order.