Skip to content

Commit

Permalink
Username cannot include special characters (#9703)
Browse files Browse the repository at this point in the history
* Username cannot include special characters

* user name validation, changelog & comments

* user name validation, comments
  • Loading branch information
jacob-nv authored and AlexAndBear committed Dec 13, 2023
1 parent f0c83f1 commit dc8b8bd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
7 changes: 7 additions & 0 deletions changelog/unreleased/bugfix-username-validation
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Bugfix: Special characters in username

Preventing special characters except for . and _ in the username.
Matching server validation for username

https://github.com/owncloud/web/issues/9694
https://github.com/owncloud/web/pull/9703
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,19 @@ export default defineComponent({
return false
}
// validate username against regex
// shouldn't contain special characters except . and _
// shouldn't start with a number
// matching regex from server side
const pattern =
"^[a-zA-Z_][a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]*(@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*)*$"
if (!new RegExp(pattern).test(this.user.onPremisesSamAccountName)) {
this.formData.userName.errorMessage = this.$gettext(
'User name cannot contain special characters'
)
return false
}
if (
this.user.onPremisesSamAccountName.length &&
!isNaN(parseInt(this.user.onPremisesSamAccountName[0]))
Expand Down

0 comments on commit dc8b8bd

Please sign in to comment.