Skip to content

Commit

Permalink
fix reauth wrong cookie issue
Browse files Browse the repository at this point in the history
  • Loading branch information
WatchAndyTW authored Jan 29, 2023
1 parent 6263bd2 commit e98d3d2
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,24 @@ async function askForSelection(valorant = new VALORANT.API()) {
data["account"]["password"] = null;
await ConfigManager.Setup();

if (fs.existsSync(`./cookies/${data["account"]["username"]}.json`)) {
let cookie = fs.readFileSync(`./cookies/${data["account"]["username"]}.json`, "utf8");
username = ConfigManager.getUsername();
password = ConfigManager.getPassword();

if (fs.existsSync(`./cookies/${username}.json`)) {
let cookie = fs.readFileSync(`./cookies/${username}.json`, "utf8");
cookie = JSON.parse(cookie);
data["cookies"] = cookie;
fs.writeFileSync("./data.json", JSON.stringify(data, null, "\t"));
await valorant.reAuthorize(data["cookies"]).catch(async (error) => {
await valorant.reAuthorize(cookie).then(async () => {
data["cookies"] = cookie;
data["account"]["username"] = username;
data["account"]["password"] = password;
}).catch(async (error) => {
console.log(error.message);
data["cookies"] = null
fs.writeFileSync("./data.json", JSON.stringify(data, null, "\t"));
});
fs.writeFileSync("./data.json", JSON.stringify(data, null, "\t"));
} else {
username = ConfigManager.getUsername()
password = ConfigManager.getPassword()
username = ConfigManager.getUsername();
password = ConfigManager.getPassword();


await valorant.authorize(username, password).then(async (error) => {
Expand Down

0 comments on commit e98d3d2

Please sign in to comment.