Skip to content

Commit

Permalink
Merge pull request #9 from puneet222/master
Browse files Browse the repository at this point in the history
Handle user logout scenario
  • Loading branch information
s-garg authored Mar 27, 2021
2 parents 626945e + ba8f8d9 commit d3af7f5
Showing 1 changed file with 28 additions and 19 deletions.
47 changes: 28 additions & 19 deletions src/actions/setup.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
// @description Setup the asana automation package
open("https://app.asana.com/0/developer-console");
click('New access token');

const tokenName: string = `workerb-${new Date().getTime()}`;
const currentURL = readURL();

type(tokenName, 'What will this token be used for?', { method: 'by_placeholder' });
if(currentURL.indexOf("login") === -1) {
// user already logged in
click('New access token');

//@ts-ignore
click('I agree to the API terms and conditions', { method: 'by_label' });
click('Create token');
const tokenName: string = `workerb-${new Date().getTime()}`;

const token = read('.CopyTextbox-text', { method: 'by_query_selector' });
type(tokenName, 'What will this token be used for?', { method: 'by_placeholder' });

notify(token, "success", 3000);
//@ts-ignore
click('I agree to the API terms and conditions', { method: 'by_label' });
click('Create token');

if (!token) {
notify("Empty token", "error", 3000)
const token = read('.CopyTextbox-text', { method: 'by_query_selector' });

notify(token, "success", 3000);

if (!token) {
notify("Empty token", "error", 3000)
} else {
setVars([
{
name: 'asanaAccessToken',
value: token,
},
], { local: true });
notify('Access token added successfully', 'success', 4000);
reIndex([]);
}
} else {
setVars([
{
name: 'asanaAccessToken',
value: token,
},
], { local: true });
notify('Access token added successfully', 'success', 3000);
reIndex([]);
}
// notify user not logged in
notify("Please login into your Asana account", "error", 3000);
}

0 comments on commit d3af7f5

Please sign in to comment.