mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-09 05:28:56 -06:00
Fix the username validation when an admin update the user
This commit is contained in:
@@ -529,7 +529,7 @@ func (i *LDAP) getGroupByDN(dn string) (*ldap.Entry, error) {
|
||||
func (i *LDAP) getGroupsForUser(dn string) ([]*ldap.Entry, error) {
|
||||
groupFilter := fmt.Sprintf(
|
||||
"(%s=%s)",
|
||||
i.groupAttributeMap.member, dn,
|
||||
i.groupAttributeMap.member, ldap.EscapeFilter(dn),
|
||||
)
|
||||
userGroups, err := i.getLDAPGroupsByFilter(groupFilter, false, false)
|
||||
if err != nil {
|
||||
|
||||
@@ -341,6 +341,14 @@ func (g Graph) PatchEducationUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if accountName, ok := changes.GetOnPremisesSamAccountNameOk(); ok {
|
||||
if !g.isValidUsername(*accountName) {
|
||||
logger.Debug().Str("username", *accountName).Msg("could not update education user: username must be at least the local part of an email")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, fmt.Sprintf("username %s must be at least the local part of an email", *changes.OnPremisesSamAccountName))
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var features []events.UserFeature
|
||||
if mail, ok := changes.GetMailOk(); ok {
|
||||
if !isValidEmail(*mail) {
|
||||
|
||||
@@ -654,6 +654,14 @@ func (g Graph) PatchUser(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if accountName, ok := changes.GetOnPremisesSamAccountNameOk(); ok {
|
||||
if !g.isValidUsername(*accountName) {
|
||||
logger.Info().Str("username", *accountName).Msg("could not update user: invalid username")
|
||||
errorcode.InvalidRequest.Render(w, r, http.StatusBadRequest, "Invalid username")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
var features []events.UserFeature
|
||||
if mail, ok := changes.GetMailOk(); ok {
|
||||
if !isValidEmail(*mail) {
|
||||
|
||||
Reference in New Issue
Block a user