MM-23244: Validate that AuthData and AuthService fields are mutually inclusive. (#14175)
* MM-23244: Validate that either both or neither AuthData and AuthService fields are set. * MM-23244: Readability improvement. * MM-23244: Adds translation. Tests for error id. * MM-23244: Fix test. Co-authored-by: mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
bfb380630c
Коммит
a9ea3587bb
@@ -219,6 +219,17 @@ func validateUserImportData(data *UserImportData) *model.AppError {
|
||||
return model.NewAppError("BulkImport", "app.import.validate_user_import_data.auth_data_length.error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
blank := func(str *string) bool {
|
||||
if str == nil {
|
||||
return true
|
||||
}
|
||||
return len(*str) == 0
|
||||
}
|
||||
|
||||
if (!blank(data.AuthService) && blank(data.AuthData)) || (blank(data.AuthService) && !blank(data.AuthData)) {
|
||||
return model.NewAppError("BulkImport", "app.import.validate_user_import_data.auth_data_and_service_dependency.error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
if data.Password != nil && len(*data.Password) == 0 {
|
||||
return model.NewAppError("BulkImport", "app.import.validate_user_import_data.password_length.error", nil, "", http.StatusBadRequest)
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user