Skip to content

Commit

Permalink
Merge pull request #147 from immers-space/username-length-and-interst…
Browse files Browse the repository at this point in the history
…itial-stuck

Username length and interstitial stuck
  • Loading branch information
wmurphyrd authored Feb 1, 2024
2 parents 17addc9 + 4ec4ac7 commit f242208
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/auth/oauthClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ function interpolateUsernameTemplate (client, ssoData) {
.replace(/\{(\w+)\}/g, (_, key) => ssoData[key] ?? '')
// strip any characters not allowed in username
.replace(/[^A-Za-z0-9-]/g, '')
// limit to max username length
.substring(0, 32)
console.log(
'Generated username from template %s and data %j: %s',
client.usernameTemplate,
Expand Down
2 changes: 1 addition & 1 deletion views/components/HandleInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class HandleInput extends React.Component {
id='username'
type='text' inputMode='email' name='username'
placeholder='username'
required pattern='^[A-Za-z0-9-]{3,32}$'
required pattern='[A-Za-z0-9\-]{3,32}'
autoCapitalize='off' autoCorrect='off' spellCheck='false'
title='Letters, numbers, & dashes only, between 3 and 32 characters'
value={this.state.username}
Expand Down
2 changes: 1 addition & 1 deletion views/oidc-interstitial/oidc-interstitial.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function RegisterForm ({ domain, fetching, setFetching }) {
}, [setFetching, setTakenMessage, setRegistrationError, setRegistrationSuccess])
useEffect(() => {
// auto-submit form when page loads if username prefilled
if (proposedUsername) {
if (proposedUsername && formEl.current.reportValidity()) {
formEl.current.dispatchEvent(
new Event('submit', { bubbles: true, cancelable: true })
)
Expand Down

0 comments on commit f242208

Please sign in to comment.