Updated alignment and validation logic on import
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 10s
This commit is contained in:
@@ -54,31 +54,28 @@ class UserImporter extends Importer
|
|||||||
public function resolveRecord(): ?User
|
public function resolveRecord(): ?User
|
||||||
{
|
{
|
||||||
$warnMsg = [];
|
$warnMsg = [];
|
||||||
|
$plantCod = $this->data['plant'];
|
||||||
$plant = null;
|
$plant = null;
|
||||||
if (Str::length($this->data['plant']) > 0) {
|
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
|
||||||
if (Str::length($this->data['plant']) < 4 || !is_numeric($this->data['plant']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['plant'])) {
|
$warnMsg[] = 'Invalid plant code found!';
|
||||||
$warnMsg[] = "Invalid plant code found!";
|
} else {
|
||||||
}
|
$plant = Plant::where('code', $plantCod)->first();
|
||||||
else {
|
|
||||||
$plant = Plant::where('code', $this->data['plant'])->first();
|
|
||||||
if (! $plant) {
|
if (! $plant) {
|
||||||
$warnMsg[] = "Plant not found";
|
$warnMsg[] = 'Plant not found';
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
$plant = $plant->id ?? null;
|
$plant = $plant->id ?? null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (Str::length($this->data['name']) < 1) {
|
if (Str::length($this->data['name']) < 3) {
|
||||||
$warnMsg[] = "User name not found!";
|
$warnMsg[] = 'Invalid user name found!';
|
||||||
}
|
}
|
||||||
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
|
// || !is_numeric($this->data['code']) || !preg_match('/^[1-9]\d{3,}$/', $this->data['code'])
|
||||||
if (Str::length($this->data['email']) < 5) {
|
if (Str::length($this->data['email']) < 5) {
|
||||||
$warnMsg[] = "Invalid email found!";
|
$warnMsg[] = 'Invalid email found!';
|
||||||
}
|
}
|
||||||
if (Str::length($this->data['password']) < 3) {
|
if (Str::length($this->data['password']) < 3) {
|
||||||
$warnMsg[] = "Invalid password found!";
|
$warnMsg[] = 'Invalid password found!';
|
||||||
}
|
}
|
||||||
// Validate roles if provided
|
// Validate roles if provided
|
||||||
$roles = [];
|
$roles = [];
|
||||||
@@ -93,9 +90,8 @@ class UserImporter extends Importer
|
|||||||
$warnMsg[] = "Role : '{$roleName}' does not exist!";
|
$warnMsg[] = "Role : '{$roleName}' does not exist!";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
$warnMsg[] = 'User roles not found!';
|
||||||
$warnMsg[] = "User roles not found!";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! empty($warnMsg)) {
|
if (! empty($warnMsg)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user