-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Ensure accounts with a private domain secondary login can create a workspace #5037
Conversation
No longer on hold! |
src/libs/actions/Report.js
Outdated
* | ||
* @param {Boolean} isFromPublicDomain | ||
*/ | ||
function updateIsFromPublicDomain(isFromPublicDomain) { |
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.
function updateIsFromPublicDomain(isFromPublicDomain) { | |
function setIsFromPublicDomain(isFromPublicDomain) { |
src/libs/getDomainFromEmail.js
Outdated
* @param {String} email | ||
* @returns {String} | ||
*/ | ||
function getDomainFromEmail(email) { |
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.
No need for this – use Str.extractEmailDomain
from expensify-common.
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.
Oooh didn't know about this... TIL! Thanks!
* @param {Boolean} [parameters.requireCertainty] | ||
* @returns {Promise} | ||
*/ | ||
function User_IsFromPublicDomain(parameters) { | ||
const commandName = 'User_IsFromPublicDomain'; | ||
requireParameters(['email'], parameters, commandName); | ||
requireParameters(['emailList'], parameters, commandName); | ||
return Network.post(commandName, { | ||
...{requireCertainty: true}, | ||
...parameters, |
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.
Am I mistaken in thinking that User_IsFromPublicDomain
expects a comma-separated list of emails instead of an array? Should this be something like:
return Network.post(commandName, {
...{
requireCertainty: true,
emailList: parameters.emailList.join(','),
},
...(_.omit(parameters, 'emailList')),
});
Or perhaps more simply:
return Network.post(commandName, {
...parameters,
...{
requireCertainty: true,
emailList: parameters.emailList.join(','),
},
});
The second is better as long as we want requireCertainty
to always be true
, which I think we do.
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.
You are right! In fact, I'm a bit confused by that too because even though we're passing an array, the request is actually sent as a comma separated list! I can't seem to find where it's being converted though 🤔
Anyway, I updated the call to User_IsFromPublicDomain
in User.js
to make it clearer.
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.
NAB but I think it would be a bit cleaner to do the .join
in here and have it take an array.
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.
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.
TIL
Updated! |
* @param {Boolean} [parameters.requireCertainty] | ||
* @returns {Promise} | ||
*/ | ||
function User_IsFromPublicDomain(parameters) { | ||
const commandName = 'User_IsFromPublicDomain'; | ||
requireParameters(['email'], parameters, commandName); | ||
requireParameters(['emailList'], parameters, commandName); | ||
return Network.post(commandName, { | ||
...{requireCertainty: true}, | ||
...parameters, |
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.
NAB but I think it would be a bit cleaner to do the .join
in here and have it take an array.
function getDomainInfo(loginList) { | ||
// If this command fails, we'll retry again in 10 minutes, | ||
// arbitrarily chosen giving Bedrock time to resolve the ClearbitCheckPublicEmail job for this email. | ||
const RETRY_TIMEOUT = 600000; |
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.
NAB: Could use a numeric seperator here:
const RETRY_TIMEOUT = 600000; | |
const RETRY_TIMEOUT = 600_000; |
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.
Ah, not your code anyway
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.
TIL about numeric separators
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
🚀 Deployed to staging by @yuwenmemon in version: 1.0.98-2 🚀
|
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.
Leaving random comments as I look at what this PR is doing.
setIsFromPublicDomain(pushJSON.isFromPublicDomain); | ||
}, false, | ||
() => { | ||
NetworkConnection.triggerReconnectionCallbacks('pusher re-subscribed to private user channel'); |
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.
Is there some reason we must call this here ?
Looks like we also do it here
App/src/libs/actions/Report.js
Line 744 in 57eed8b
NetworkConnection.triggerReconnectionCallbacks('pusher re-subscribed to private user channel'); |
and here
App/src/libs/actions/Report.js
Line 724 in 57eed8b
NetworkConnection.triggerReconnectionCallbacks('pusher re-subscribed to private user channel'); |
and here
App/src/libs/actions/Report.js
Line 704 in 57eed8b
NetworkConnection.triggerReconnectionCallbacks('pusher re-subscribed to private user channel'); |
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.
Just a bad example copied over? We already call triggerReconnectionCallbacks
when a user comes back online in listenForReconnect
. All these calls seem unnecessary then. I can refactor that on v2 of this PR.
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.
Ah ok, maybe or we can create a follow up to look into a better way. Probably shouldn't need to block these changes. Just thought it was worth mentioning.
* | ||
* @param {String} loginList | ||
*/ | ||
function getDomainInfo(loginList) { |
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.
I am probably just not seeing why it's necessary but we can access the loginList
from Web-Expensify so I'm confused about why we pass it as a parameter here?
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.
The idea is that we would filter the loginList
on the frontend and only make API calls with logins that are not in the common domain list. So for example, if the loginList
was ['[email protected]', '[email protected]', '[email protected]']
we would only call the API to check [email protected]
. If we were to access the loginList
in Web-E, we would have to filter the list again.
} else { | ||
// eslint-disable-next-line max-len | ||
console.debug(`Command User_IsFromPublicDomain returned error code: ${response.jsonCode}. Most likely, this means that the domain ${Str.extractEmail(sessionEmail)} is not in the bedrock cache. Retrying in ${RETRY_TIMEOUT / 1000 / 60} minutes`); | ||
setTimeout(() => getDomainInfo(loginList), RETRY_TIMEOUT); |
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.
It's not great to leave timers running because it can lead to stuff like this function getting called when a user is logged out.
This should help ->
Lines 11 to 27 in 57eed8b
function register(timerID) { | |
timers.push(timerID); | |
return timerID; | |
} | |
/** | |
* Clears all timers that we have registered. Use for long running tasks that may begin once logged out. | |
*/ | |
function clearAll() { | |
_.each(timers, (timer) => { | |
// We don't know whether it's a setTimeout or a setInterval, but it doesn't really matter. If the id doesn't | |
// exist nothing bad happens. | |
clearTimeout(timer); | |
clearInterval(timer); | |
}); | |
} | |
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.
TIL
Details
Ensure accounts with a private domain secondary login can create a workspace via the "Get Started" button in workspace configuration.
Related Web-E PR: https://github.com/Expensify/Web-Expensify/pull/31862
cc @roryabraham
Fixed Issues
$ https://github.com/Expensify/Expensify/issues/176225
Tests
@gmail.com
.+ > New Workspace
and verify that you seeAdd Email
in the card page.Add email
.@expensify.com
.Get Started
and clicking it starts the VBA flow.QA Steps
Steps above.
Tested On
Screenshots
Web
web.mov
Mobile Web
Desktop
desktop.mov
iOS
Android