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

Added shared account selection module based on the old python API #64

Merged
merged 1 commit into from
Oct 6, 2023

Conversation

awkrupka
Copy link
Contributor

@awkrupka awkrupka commented Oct 4, 2023

User can now change his account to one of the accounts shared with him (company and clients) while interacting with the backend. This can be done in one of two ways, by calling:

import flow360 as fl

fl.Accounts.choose_shared_account(<email_address>)

where the account will be switched if the provided email address exists and is shared with the current user or

import flow360 as fl

fl.Accounts.choose_shared_account()

where the user will be prompted to select an account from the list interactively.

Choosing account in interactive mode, please select email from the organization list: 
0: lei@flexcompute.com
1: thomas@flexcompute.com
2: qiqi@flexcompute.com
3: yuwei@flexcompute.com
4: chaitanya@flexcompute.com
5: ben@flexcompute.com
6: runda@flexcompute.com
7: jim@flexcompute.com
8: lin@flexcompute.com
9: james@flexcompute.com
10: yongwei@flexcompute.com
11: maciej@flexcompute.com
12: cj@flexcompute.com
13: feilin@flexcompute.com
Enter address of the account to switch to [0 - 13] or 'q' to abort:

When submitting resources to the server while using a shared account, the user is prompted to confirm the action:

WARNING: You are submitting a resource to a shared account maciej@flexcompute.com.                                             
         This message will not be shown again for this session if you confirm.                                                            
                                                                               
Are you sure you want to proceed? (y/n): 

This message shows once per session until the user logs out if the user confirms interactively or by calling

fl.Accounts.confirm_submit()

NOTE: Due to backend issues we currently do not support client accounts, as apikey authentication does not seem to work when requesting their data from the webapi. This will be fixed separately.

@awkrupka awkrupka force-pushed the andrzej/account_selection branch from 2904f12 to 523db63 Compare October 4, 2023 12:40
Comment on lines 13 to 16
shared_submit_warning = """\
You are submitting a resource from a shared account.
To suppress this message run: flow360 configure --suppress-shared-account-prompt
"""
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think the message should read:
You are submitting a resource to a shared account (email address).

Copy link
Contributor Author

@awkrupka awkrupka Oct 4, 2023

Choose a reason for hiding this comment

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

Fixed in 5035ff0 - the message is updated and confirmation now works per-session and needs to be performed only once until the user logs out, either interactively or by the user calling

fl.Accounts.confirm_submit()


selected = None

addresses = [d["userEmail"] for d in company_users]
Copy link
Collaborator

Choose a reason for hiding this comment

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

we try to avoid single letter variables, even in such instances. Use user instead

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to user in 644f8ee

user email to impersonate (if email exists among shared accounts),
if email is not provided user can select the account interactively
"""
company_users = self._get_company_users()
Copy link
Collaborator

Choose a reason for hiding this comment

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

lets use a list that will have both company users and supported users. Supported in future. Suggest a name shared_accounts

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Renamed to shared_accounts in 644f8ee

@@ -48,6 +50,31 @@ def wrapper_func(*args, **kwargs):
return wrapper


def confirm_proceed():
Copy link
Collaborator

Choose a reason for hiding this comment

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

rename function:
shared_account_confirm_proceed() or something similar to indicate that this confirmation is only in case of shared account

Copy link
Contributor Author

@awkrupka awkrupka Oct 4, 2023

Choose a reason for hiding this comment

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

Renamed to shared_account_confirm_submit() in 2e584f1

flow360/log.py Outdated
@@ -289,7 +289,7 @@ def set_logging_file(
filemode: str = "a",
level: LogValue = DEFAULT_LEVEL,
back_up_count: int = 10,
max_bytes: int = 10000,
max_bytes: int = 100000000,
Copy link
Collaborator

Choose a reason for hiding this comment

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

why changing this again? Is it a conflict?

Copy link
Contributor Author

@awkrupka awkrupka Oct 4, 2023

Choose a reason for hiding this comment

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

Accidentally changed when running tests to speed up the process before merging with FLPY-35 fix. Reverting in next commit to prevent conflict.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted in 644f8ee

@awkrupka awkrupka force-pushed the andrzej/account_selection branch 3 times, most recently from fb447bd to 2e584f1 Compare October 4, 2023 20:14

return self._current_email

def leave_shared_account(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

on leave, we should reset the submit confirm question

@awkrupka awkrupka force-pushed the andrzej/account_selection branch from 2e584f1 to 3441504 Compare October 6, 2023 06:56
@awkrupka awkrupka merged commit 579f543 into develop Oct 6, 2023
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.

2 participants