Skip to content

Commit 2ef60c9

Browse files
committed
prevent creation of new OAuth if ShieldOAuthConfig.php is missing
1 parent 8c0a34a commit 2ef60c9

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/Commands/Generators/NewShieldOauthGenerator.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,15 @@ public function run(array $params): int
111111

112112
$params[0] = $class;
113113

114+
// ShieldOAuthConfig file must be present
115+
if ($this->updateConfig($class) !== 0) {
116+
CLI::error('ShieldOAuthConfig.php does not exist. Please run `php spark make:oauthconfig` first.', 'light_gray', 'red');
117+
118+
return 1;
119+
}
114120
// @TODO execute() is deprecated in CI v4.3.0.
115121
$this->execute($params); // @phpstan-ignore-line suppress deprecated error.
116122

117-
// Update config
118-
$this->updateConfig($class);
119-
120123
return 0;
121124
}
122125

@@ -130,8 +133,6 @@ private function updateConfig($className): int
130133
// Check that the config file exists
131134
$file = 'Config/ShieldOAuthConfig.php';
132135
if (! is_file($this->distPath . $file)) {
133-
CLI::error('ShieldOAuthConfig.php does not exist. Please run `php spark make:oauthconfig` first.', 'light_gray', 'red');
134-
135136
return 1;
136137
}
137138

0 commit comments

Comments
 (0)