-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
Block system user from Inviting into Workspace #4781
Changes from 4 commits
5bc0f4f
8c6c736
0896cc7
242734b
f238c73
b710d97
aabda01
32f41f9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -588,12 +588,14 @@ export default { | |
}, | ||
invite: { | ||
invitePeople: 'Invite People', | ||
invitePeoplePrompt: 'Invite a colleague to your workspace.', | ||
invitePeoplePrompt: 'Invite colleagues to your workspace.', | ||
personalMessagePrompt: 'Add a Personal Message (Optional)', | ||
enterEmailOrPhone: 'Email or Phone', | ||
enterEmailOrPhone: 'Emails or Phones', | ||
EmailOrPhonePlaceholder: 'Enter comma-separated emails or phones', | ||
roryabraham marked this conversation as resolved.
Show resolved
Hide resolved
|
||
pleaseEnterValidLogin: 'Please ensure the email or phone number is valid (e.g. +15005550006).', | ||
pleaseEnterUniqueLogin: 'That user is already a member of this workspace.', | ||
genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', | ||
systemUserError: 'Please ensure email or phone number is not a system User.', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coming back from the linked issue, the copy we landed on here is:
Using whichever invalid email was found first. |
||
welcomeNote: ({workspaceName}) => `You have been invited to the ${workspaceName} Workspace! Download the Expensify mobile App to start tracking your expenses.`, | ||
}, | ||
editor: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -152,6 +152,20 @@ function isConciergeChatReport(report) { | |
&& report.participants[0] === CONST.EMAIL.CONCIERGE; | ||
} | ||
|
||
/** | ||
* Whether a login is system email | ||
* | ||
* @param {String} login - user email | ||
* @return {Boolean} | ||
*/ | ||
function isSystemUser(login) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NAB but |
||
return [ | ||
CONST.EMAIL.CONCIERGE, | ||
CONST.EMAIL.CHRONOS, | ||
CONST.EMAIL.RECEIPTS, | ||
].includes(login); | ||
} | ||
|
||
export { | ||
getReportParticipantsTitle, | ||
isReportMessageAttachment, | ||
|
@@ -163,4 +177,5 @@ export { | |
getDefaultRoomSubtitle, | ||
isArchivedRoom, | ||
isConciergeChatReport, | ||
isSystemUser, | ||
}; |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -20,6 +20,8 @@ import Growl from '../../libs/Growl'; | |||||
import ExpensiTextInput from '../../components/ExpensiTextInput'; | ||||||
import FixedFooter from '../../components/FixedFooter'; | ||||||
import KeyboardAvoidingView from '../../components/KeyboardAvoidingView'; | ||||||
import {isSystemUser} from '../../libs/reportUtils'; | ||||||
import {addSMSDomainIfPhoneNumber} from '../../libs/OptionsListUtils'; | ||||||
|
||||||
const propTypes = { | ||||||
...withLocalizePropTypes, | ||||||
|
@@ -88,9 +90,16 @@ class WorkspaceInvitePage extends React.Component { | |||||
Growl.error(this.props.translate('workspace.invite.pleaseEnterValidLogin'), 5000); | ||||||
return; | ||||||
} | ||||||
|
||||||
const isEnteredLoginSystemLogin = _.some(logins, login => isSystemUser(login)); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
if (isEnteredLoginSystemLogin) { | ||||||
Growl.error(this.props.translate('workspace.invite.systemUserError'), 5000); | ||||||
return; | ||||||
} | ||||||
|
||||||
const policyEmployeeList = lodashGet(this.props, 'policy.employeeList', []); | ||||||
const AreLoginsDuplicate = _.every(logins, login => _.contains(policyEmployeeList, login)); | ||||||
if (AreLoginsDuplicate) { | ||||||
const areLoginsDuplicate = _.some(logins, login => _.contains(policyEmployeeList, addSMSDomainIfPhoneNumber(login))); | ||||||
if (areLoginsDuplicate) { | ||||||
Growl.error(this.props.translate('workspace.invite.pleaseEnterUniqueLogin'), 5000); | ||||||
return; | ||||||
} | ||||||
|
@@ -116,6 +125,7 @@ class WorkspaceInvitePage extends React.Component { | |||||
<ExpensiTextInput | ||||||
ref={el => this.emailOrPhoneInputRef = el} | ||||||
label={this.props.translate('workspace.invite.enterEmailOrPhone')} | ||||||
placeholder={this.props.translate('workspace.invite.EmailOrPhonePlaceholder')} | ||||||
autoCompleteType="email" | ||||||
autoCorrect={false} | ||||||
autoCapitalize="none" | ||||||
|
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.