-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from puneet222/master
Handle user logout scenario
- Loading branch information
Showing
1 changed file
with
28 additions
and
19 deletions.
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
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); | ||
} |