Skip to content

Commit

Permalink
Update _worker.js
Browse files Browse the repository at this point in the history
  • Loading branch information
jyx04 authored Jun 9, 2024
1 parent 80da917 commit 168636e
Showing 1 changed file with 27 additions and 4 deletions.
31 changes: 27 additions & 4 deletions _worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ async function handleRequest(request) {
const chatlogourl = await KV.get('ChatLogoURL') || await KV.get('LogoURL') || logo;
const chatusername = await KV.get('ChatUserName') || 'Haibara AI';
const chatmail = await KV.get('ChatMail') || 'Power by Pandora';
const cookies = request.headers.get('Cookie');
let aian = '';
if (cookies) {
const cookiesArray = cookies.split(';');
for (const cookie of cookiesArray) {
const [name, value] = cookie.trim().split('=');
if (name === 'aian') {
aian = value;
}
}
}

//处理直链登陆形式
const params = new URLSearchParams(url.search);
Expand Down Expand Up @@ -181,16 +192,16 @@ async function handleRequest(request) {
const data = await response.json();
data.picture = `${chatlogourl}`;
data.email = `${chatmail}`;
data.name = `${chatusername}`;
data.name = `${chatusername} [${aian}]`;
return new Response(JSON.stringify(data), {
status: response.status,
headers: response.headers
});
}
if (url.pathname === '/backend-api/gizmo_creator_profile') {
const data = await response.json();
data.name = `${chatusername}`;
data.display_name = `${chatusername}`;
data.name = `${chatusername} [${aian}]`;
data.display_name = `${chatusername} [${aian}]`;
return new Response(JSON.stringify(data), {
status: response.status,
headers: response.headers
Expand Down Expand Up @@ -2834,7 +2845,19 @@ accountNumber = await getAccountNumber(fullUserName,initialaccountNumber, antype
// Log the successful login
await loginlog(fullUserName, accountNumber, antype);

return Response.redirect(await getOAuthLink(shareToken, proxiedDomain), 302);
const oauthLink = await getOAuthLink(shareToken, proxiedDomain);
//const passwd = await generatePassword(userName);
const headers = new Headers();
headers.append('Location', oauthLink);
//headers.append('Set-Cookie', `aina=${passwd}; Path=/`);
headers.append('Set-Cookie', `aian=${accountNumber}; Path=/`);


const response = new Response(null, {
status: 302,
headers: headers
});
return response;
}

async function loginlog(userName, accountNumber, antype) {
Expand Down

0 comments on commit 168636e

Please sign in to comment.