Skip to content
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

Username length and interstitial stuck #147

Merged
merged 2 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading