Skip to content

Commit

Permalink
task/WP-685: user work workspace file select (#1426)
Browse files Browse the repository at this point in the history
* handle error in revoke method

* handle cloud.data work system in workspace select modal
  • Loading branch information
rstijerina authored Sep 16, 2024
1 parent 73444b7 commit 1de0935
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
1 change: 1 addition & 0 deletions client/modules/_hooks/src/systems/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export type TTapisSystem = {
label?: string;
keyservice?: boolean;
isMyData?: boolean;
hasWork?: boolean;
portalNames: string[];
};
importRefId?: string;
Expand Down
16 changes: 11 additions & 5 deletions client/modules/workspace/src/SelectModal/SelectModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,13 @@ const getSystemRootPath = (
storageSystem: TTapisSystem | undefined,
user: TUser | undefined
): string => {
return storageSystem?.notes?.isMyData
? encodeURIComponent('/' + user?.username)
: '';
if (storageSystem?.notes?.isMyData) {
return encodeURIComponent('/' + user?.username);
}
if (storageSystem?.notes?.hasWork) {
return encodeURIComponent('/work/' + user?.homedir);
}
return '';
};

const getBackPath = (
Expand Down Expand Up @@ -298,7 +302,7 @@ export const SelectModal: React.FC<{
return (a.notes?.isMyData ? 0 : 1) - (b.notes?.isMyData ? 0 : 1);
})
.map((system) => ({
label: system.notes.label,
label: system.notes?.hasWork ? 'Work' : system.notes.label ?? system.id,
value: system.id,
}));
systemOptions.push({ label: 'My Projects', value: 'myprojects' });
Expand Down Expand Up @@ -363,7 +367,9 @@ export const SelectModal: React.FC<{
selectedPath: getSystemRootPath(system, user),
scheme: getScheme(system),
});
setSystemLabel(system.notes.label ?? system.id);
setSystemLabel(
system.notes?.hasWork ? 'Work' : system.notes.label ?? system.id
);
};

const onProjectSelect = (uuid: string, projectId: string) => {
Expand Down
18 changes: 12 additions & 6 deletions designsafe/apps/auth/backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ def on_user_logged_out(sender, request, user, **kwargs):
login_provider = "TACC"

logger.info(
"Revoking tapis token: %s", TapisOAuthToken().get_masked_token(user.tapis_oauth.access_token)
"Revoking tapis token: %s",
TapisOAuthToken().get_masked_token(user.tapis_oauth.access_token),
)
backend = TapisOAuthBackend()
TapisOAuthBackend.revoke(backend, user.tapis_oauth.access_token)
Expand Down Expand Up @@ -139,7 +140,8 @@ def authenticate(self, *args, **kwargs):
token = kwargs["token"]

logger.info(
'Attempting login via Tapis with token "%s"' % TapisOAuthToken().get_masked_token(token)
'Attempting login via Tapis with token "%s"'
% TapisOAuthToken().get_masked_token(token)
)
client = Tapis(base_url=settings.TAPIS_TENANT_BASEURL, access_token=token)

Expand Down Expand Up @@ -188,9 +190,13 @@ def authenticate(self, *args, **kwargs):

def revoke(self, token):
logger.info(
"Attempting to revoke Tapis token %s" % TapisOAuthToken().get_masked_token(token)
"Attempting to revoke Tapis token %s"
% TapisOAuthToken().get_masked_token(token)
)

client = Tapis(base_url=settings.TAPIS_TENANT_BASEURL, access_token=token)
response = client.authenticator.revoke_token(token=token)
logger.info("revoke response is %s" % response)
try:
client = Tapis(base_url=settings.TAPIS_TENANT_BASEURL, access_token=token)
response = client.authenticator.revoke_token(token=token)
logger.info("revoke response is %s" % response)
except BaseTapyException as e:
logger.error("Error revoking token: %s", e.message)

0 comments on commit 1de0935

Please sign in to comment.