Skip to content

Commit 2d57d49

Browse files
committed
updated getSigninAPi
1 parent c09e510 commit 2d57d49

File tree

2 files changed

+19
-27
lines changed

2 files changed

+19
-27
lines changed

actions/login.js

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,42 @@
11
const { v4: uuidv4 } = require('uuid');
2-
const axios = require('axios')
3-
const fs = require('fs');
2+
const axios = require('axios');
43
const chalk = require('chalk');
5-
const { saveUserData, getUserData, checkUserAuth, deleteUserData } = require('./userData');
6-
7-
// Function to delete the users.json file
8-
4+
const { saveUserData, checkUserAuth, deleteUserData } = require('./userData');
95

106
// Function to log out the user
117
const logout = () => {
128
deleteUserData();
139
console.log('Logged out successfully');
1410
};
1511

16-
12+
// Function to sign in the user
1713
const signIn = () => {
1814
if (checkUserAuth()) {
1915
console.log(chalk.yellow('Already logged in.'));
2016
} else {
2117
const uuid = uuidv4();
22-
2318
console.log(chalk.blue(`Please open this URL to login: http://portal.codebolt.ai/performSignIn?uid=${uuid}&loginflow=app`));
24-
19+
2520
const intervalId = setInterval(async () => {
26-
try {
27-
// const response = await axios.get(
28-
// `https://us-central1-codeboltai.cloudfunctions.net/checkOneTimeToken?oneTimeToken=${uuid}`
29-
// );
30-
const response = await axios.get(
31-
`https://api.codebolt.ai/api/auth/addonetimetoken?oneTimeToken=${uuid}`
32-
);
21+
try {
22+
console.log(`https://api.codebolt.ai/api/auth/addonetimetoken?oneTimeToken=${uuid}`);
23+
const response = await axios.post(
24+
`https://api.codebolt.ai/api/auth/addonetimetoken?oneTimeToken=${uuid}`
25+
);
3326

34-
if (response.status === 200) {
35-
clearInterval(intervalId);
36-
console.log(chalk.green('Login successful!'));
37-
saveUserData(response.data);
27+
if (response.status === 200) {
28+
clearInterval(intervalId);
29+
console.log(chalk.green('Login successful!'));
30+
saveUserData(response.data);
31+
}
32+
} catch (error) {
33+
console.error(chalk.red('Error checking token:', error));
3834
}
39-
// Assuming there is a function saveUserApiResponse to handle saving the response
40-
} catch (error) {
41-
// console.log('Error checking token:', error);
42-
}
4335
}, 1000);
4436
}
4537
};
4638

47-
module.exports={
39+
module.exports = {
4840
signIn,
4941
logout
50-
}
42+
};

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codebolt-cli",
3-
"version": "1.1.20",
3+
"version": "1.1.21",
44
"description": "A CLI tool for version checking and folder uploads",
55
"main": "codebolt.js",
66
"bin": {

0 commit comments

Comments
 (0)