Skip to content

Commit

Permalink
[MM-16149] Fix username validation message for Bot creation. (matterm…
Browse files Browse the repository at this point in the history
…ost#2988)

* check username validation with utils function.  Otherwise, error is
handled server-side with actually does not enforce the a username to
start with [a-z]

* refactor.  Catch usernameError before we even attempt server-side bot
creation call
  • Loading branch information
jfrerich authored and cpoile committed Jun 21, 2019
1 parent 0a7b321 commit 2837f7a
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions components/integrations/bots/add_bot/add_bot.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,15 @@ export default class AddBot extends React.Component {
return;
}
} else {
const usernameError = Utils.isValidUsername(bot.username);
if (usernameError) {
this.setState({
adding: false,
error: usernameError,
});
return;
}

const result = await this.props.actions.createBot(bot);
if (result) {
data = result.data;
Expand Down

0 comments on commit 2837f7a

Please sign in to comment.