mirror of
https://github.com/calli-eve/eve-pi.git
synced 2026-02-13 11:18:47 +01:00
Add system variable to character
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { AccessToken } from "@/types";
|
||||
import { extractCharacterFromToken } from "@/utils";
|
||||
import crypto from "crypto-js";
|
||||
import { NextApiRequest, NextApiResponse } from "next";
|
||||
import crypto from "crypto-js";
|
||||
|
||||
const EVE_SSO_TOKEN_URL = "https://login.eveonline.com/v2/oauth/token";
|
||||
const EVE_SSO_CLIENT_ID = process.env.EVE_SSO_CLIENT_ID ?? "";
|
||||
@@ -14,14 +14,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
grant_type: "refresh_token",
|
||||
refresh_token: crypto.AES.decrypt(
|
||||
accessToken.refresh_token,
|
||||
EVE_SSO_SECRET
|
||||
EVE_SSO_SECRET,
|
||||
).toString(crypto.enc.Utf8),
|
||||
}).toString();
|
||||
|
||||
const headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Authorization: `Basic ${Buffer.from(
|
||||
`${EVE_SSO_CLIENT_ID}:${EVE_SSO_SECRET}`
|
||||
`${EVE_SSO_CLIENT_ID}:${EVE_SSO_SECRET}`,
|
||||
).toString("base64")}`,
|
||||
Host: "login.eveonline.com",
|
||||
"User-Agent": "https://github.com/calli-eve/eve-pi",
|
||||
@@ -40,13 +40,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
token_type: response.token_type,
|
||||
refresh_token: crypto.AES.encrypt(
|
||||
response.refresh_token,
|
||||
EVE_SSO_SECRET
|
||||
EVE_SSO_SECRET,
|
||||
).toString(),
|
||||
expires_at: Date.now() + response.expires_in * 1000,
|
||||
character,
|
||||
needsLogin: false,
|
||||
account: accessToken.account,
|
||||
comment: accessToken.comment
|
||||
comment: accessToken.comment,
|
||||
system: accessToken.system,
|
||||
};
|
||||
|
||||
console.log("Refresh", character.name, character.characterId);
|
||||
|
||||
@@ -20,7 +20,7 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
const headers = {
|
||||
"Content-Type": "application/x-www-form-urlencoded",
|
||||
Authorization: `Basic ${Buffer.from(
|
||||
`${EVE_SSO_CLIENT_ID}:${EVE_SSO_SECRET}`
|
||||
`${EVE_SSO_CLIENT_ID}:${EVE_SSO_SECRET}`,
|
||||
).toString("base64")}`,
|
||||
Host: "login.eveonline.com",
|
||||
"User-Agent": "https://github.com/calli-eve/eve-pi",
|
||||
@@ -41,13 +41,14 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
|
||||
token_type: response.token_type,
|
||||
refresh_token: crypto.AES.encrypt(
|
||||
response.refresh_token,
|
||||
EVE_SSO_SECRET
|
||||
EVE_SSO_SECRET,
|
||||
).toString(),
|
||||
expires_at: Date.now() + response.expires_in * 1000,
|
||||
character,
|
||||
needsLogin: false,
|
||||
account: "-",
|
||||
comment: "",
|
||||
system: "",
|
||||
};
|
||||
res.json(token);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user