@devquest/cli 1.0.1 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/commands/auth.js +13 -4
- package/package.json +1 -1
package/dist/commands/auth.js
CHANGED
|
@@ -33,6 +33,7 @@ exports.authCommand = new commander_1.Command('auth')
|
|
|
33
33
|
const url = new URL(req.url || '/', `http://localhost:${PORT}`);
|
|
34
34
|
if (url.pathname === '/callback') {
|
|
35
35
|
const token = url.searchParams.get('token');
|
|
36
|
+
const redirectUrl = url.searchParams.get('redirect');
|
|
36
37
|
if (token) {
|
|
37
38
|
try {
|
|
38
39
|
if (!fs_1.default.existsSync(CONFIG_DIR)) {
|
|
@@ -41,13 +42,21 @@ exports.authCommand = new commander_1.Command('auth')
|
|
|
41
42
|
const config = fs_1.default.existsSync(CONFIG_FILE) ? JSON.parse(fs_1.default.readFileSync(CONFIG_FILE, 'utf-8')) : {};
|
|
42
43
|
config.token = token;
|
|
43
44
|
fs_1.default.writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
if (redirectUrl) {
|
|
46
|
+
res.writeHead(302, { 'Location': redirectUrl });
|
|
47
|
+
res.end();
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
51
|
+
res.end(JSON.stringify({ success: true }));
|
|
52
|
+
}
|
|
46
53
|
console.log(chalk_1.default.green('\n✅ Autenticado com sucesso! Seu token foi guardado localmente protegido.'));
|
|
47
54
|
console.log(chalk_1.default.yellow('Agora você pode clonar e submeter desafios!'));
|
|
48
55
|
console.log(chalk_1.default.gray('Use: devquest clone <id-do-curso>'));
|
|
49
|
-
|
|
50
|
-
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
server.close();
|
|
58
|
+
process.exit(0);
|
|
59
|
+
}, 100);
|
|
51
60
|
}
|
|
52
61
|
catch (err) {
|
|
53
62
|
console.error('\nErro ao salvar token de forma segura:', err);
|