fix(admin): bind token form to dotted scope to escape ng-if child scope

The Generate button silently no-op'd because ng-model="newTokenName" inside
an ng-if block wrote to a child scope, leaving $scope.newTokenName empty.
Use $scope.tokenForm.{name,plaintext} so prototypal lookup resolves to the
controller scope.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
tdurieux
2026-05-03 19:40:28 +02:00
parent 9f1ae1924b
commit e18961208a
3 changed files with 11 additions and 11 deletions
+5 -6
View File
@@ -199,8 +199,7 @@ angular
getUserRepositories($routeParams.username);
$scope.tokens = [];
$scope.newTokenName = "";
$scope.newTokenPlaintext = null;
$scope.tokenForm = { name: "", plaintext: null };
function loadTokens() {
$http.get("/api/admin/tokens").then(
@@ -215,13 +214,13 @@ angular
loadTokens();
$scope.createToken = () => {
if (!$scope.newTokenName) return;
if (!$scope.tokenForm.name) return;
$http
.post("/api/admin/tokens", { name: $scope.newTokenName })
.post("/api/admin/tokens", { name: $scope.tokenForm.name })
.then(
(res) => {
$scope.newTokenPlaintext = res.data.token;
$scope.newTokenName = "";
$scope.tokenForm.plaintext = res.data.token;
$scope.tokenForm.name = "";
loadTokens();
},
(err) => console.error(err)