Skip to content

Commit 2c28b9d

Browse files
Alexey PortnovAlexey Portnov
authored andcommitted
fix(advice,routes): resolve stale password warning and pattern truncation
1. Password change warning persists after changing default password: - ReloadAdviceAction now publishes fresh advice to EventBus after clearing cache, replacing stale nchan messages immediately - GetAdviceListAction always publishes to EventBus (even empty results) to evict outdated warnings from nchan message store 2. Outbound route numberbeginswith field truncated at 20 chars: - Increased maxLength from 20 to 64 in DataStructure to match the regex validation limit, allowing patterns like (7|8)(70|71|72|73|74|75) (27 chars)
1 parent 207258f commit 2c28b9d

3 files changed

Lines changed: 16 additions & 4 deletions

File tree

src/Core/Workers/Libs/WorkerModelsEvents/Actions/ReloadAdviceAction.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
use MikoPBX\Core\Workers\Libs\WorkerPrepareAdvice\CheckSSHPasswords;
3636
use MikoPBX\Core\Workers\Libs\WorkerPrepareAdvice\CheckWebPasswords;
3737
use MikoPBX\Core\Workers\WorkerPrepareAdvice;
38+
use MikoPBX\PBXCoreREST\Lib\Advice\GetAdviceListAction;
3839
use Phalcon\Di\Di;
3940

4041
class ReloadAdviceAction implements ReloadActionInterface
@@ -90,5 +91,13 @@ public function execute(array $parameters = []): void
9091
SystemMessages::sysLogMsg(__METHOD__, "Cache key $cacheKey deleted on reload advice", LOG_DEBUG);
9192
}
9293
}
94+
95+
// Publish fresh advice to EventBus immediately after clearing cache.
96+
// Without this, nchan retains the last stored message (with stale warnings),
97+
// and new page loads receive the outdated advice — causing redirect loops
98+
// (e.g., default password warning persists after password change).
99+
if (!empty($parameters)) {
100+
GetAdviceListAction::main();
101+
}
93102
}
94103
}

src/PBXCoreREST/Lib/Advice/GetAdviceListAction.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,12 @@ public static function main(): PBXApiResult
7171
}
7272
}
7373
$res->data['advice'] = $result;
74-
if (count($result) > 0) {
75-
$di->get(EventBusProvider::SERVICE_NAME)->publish('advice', $res->getResult());
76-
}
74+
75+
// Always publish to EventBus, even when result is empty.
76+
// This replaces stale nchan messages (e.g., after password change clears the warning).
77+
// Without this, nchan retains the last stored message with outdated warnings.
78+
$di->get(EventBusProvider::SERVICE_NAME)->publish('advice', $res->getResult());
79+
7780
return $res;
7881
}
7982

src/PBXCoreREST/Lib/OutboundRoutes/DataStructure.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ private static function getAllFieldDefinitions(): array
337337
'numberbeginswith' => [
338338
'type' => 'string',
339339
'description' => 'rest_schema_obr_numberbeginswith',
340-
'maxLength' => 20,
340+
'maxLength' => 64,
341341
'sanitize' => 'string',
342342
'example' => '00'
343343
],

0 commit comments

Comments
 (0)