huoxingren 0.1.0 → 0.1.1
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/package.json +1 -1
- package/src/commands/login.js +13 -8
- package/src/index.js +1 -1
package/package.json
CHANGED
package/src/commands/login.js
CHANGED
|
@@ -22,13 +22,16 @@ export async function login(opts) {
|
|
|
22
22
|
const anonKey = url.searchParams.get('anon_key');
|
|
23
23
|
if (token) {
|
|
24
24
|
saveConfig({ token, apiUrl: platformUrl, ...(anonKey ? { anonKey } : {}) });
|
|
25
|
-
|
|
26
|
-
res.
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
25
|
+
const dashboardUrl = `${platformUrl}/#/dashboard`;
|
|
26
|
+
res.writeHead(302, { Location: dashboardUrl });
|
|
27
|
+
res.end();
|
|
28
|
+
console.log('✔ 登录成功!凭证已保存到 ~/.huoxingren/config.json');
|
|
29
|
+
server.close(() => {
|
|
30
|
+
resolve();
|
|
31
|
+
process.exit(0);
|
|
32
|
+
});
|
|
30
33
|
} else {
|
|
31
|
-
res.writeHead(400);
|
|
34
|
+
res.writeHead(400, { 'Content-Type': 'text/plain; charset=utf-8' });
|
|
32
35
|
res.end('缺少 token');
|
|
33
36
|
}
|
|
34
37
|
} else {
|
|
@@ -47,8 +50,10 @@ export async function login(opts) {
|
|
|
47
50
|
|
|
48
51
|
setTimeout(() => {
|
|
49
52
|
console.log('登录超时(2分钟)。请重试。');
|
|
50
|
-
server.close()
|
|
51
|
-
|
|
53
|
+
server.close(() => {
|
|
54
|
+
resolve();
|
|
55
|
+
process.exit(1);
|
|
56
|
+
});
|
|
52
57
|
}, 120000);
|
|
53
58
|
});
|
|
54
59
|
}
|