Skip to content

done#38

Merged
toaru005 merged 1 commit intotoaru-blockchainfrom
toaru-done
Feb 21, 2026
Merged

done#38
toaru005 merged 1 commit intotoaru-blockchainfrom
toaru-done

Conversation

@toaru005
Copy link
Contributor

No description provided.

Copilot AI review requested due to automatic review settings February 21, 2026 17:42
@toaru005 toaru005 merged commit fec6bba into toaru-blockchain Feb 21, 2026
1 of 2 checks passed
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates authentication flow in the workspace backend by issuing a login cookie during registration and adjusting the login submit route middleware.

Changes:

  • Issue LOGIN_TOKEN cookie after successful registration.
  • Remove InverseVCM middleware from POST /Login/Submit.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
Backend/Workspace/Routes/Register.js Adds CreateCookie call to issue LOGIN_TOKEN during registration.
Backend/Workspace/Routes/Login.js Removes InverseVCM from the login submit endpoint.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +181 to +190
// 4. Cookie発行
CreateCookie({
res,
cookieName: 'LOGIN_TOKEN',
payload: { userId, address: address },
secretKey: process.env.LOGIN_SECRET,
deadlineHours: 24, // 1日有効
httpOnly: true,
sameSite: 'strict'
});
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CreateCookie is used here but Register.js does not import it (there are no other references in this file). This will throw ReferenceError: CreateCookie is not defined at runtime; add the appropriate import (matching how Login.js imports it from ../Tools/CreateCookie.js).

Copilot uses AI. Check for mistakes.
Comment on lines +181 to +191
// 4. Cookie発行
CreateCookie({
res,
cookieName: 'LOGIN_TOKEN',
payload: { userId, address: address },
secretKey: process.env.LOGIN_SECRET,
deadlineHours: 24, // 1日有効
httpOnly: true,
sameSite: 'strict'
});

Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This issues the login cookie before the user record is persisted. If the DB insert fails (or the request errors after cookie issuance), the client can end up holding a valid LOGIN_TOKEN for a userId/address that was never saved. Move cookie issuance to after the DB insert succeeds (and consider clearing any already-set cookie on error paths).

Copilot uses AI. Check for mistakes.
Comment on lines +185 to +187
payload: { userId, address: address },
secretKey: process.env.LOGIN_SECRET,
deadlineHours: 24, // 1日有効
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

secretKey: process.env.LOGIN_SECRET can be undefined, which causes jwt.sign inside CreateCookie to throw ("secretOrPrivateKey must have a value"). Consider validating LOGIN_SECRET (similar to the existing PEPPER check) and returning a configuration error before attempting to create the cookie.

Copilot uses AI. Check for mistakes.
cookieName: 'LOGIN_TOKEN',
payload: { userId, address: address },
secretKey: process.env.LOGIN_SECRET,
deadlineHours: 24, // 1日有効
Copy link

Copilot AI Feb 21, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment says "1日有効", but CreateCookie currently sets only { httpOnly, sameSite } on the cookie (no maxAge/expires), so the browser cookie itself is session-scoped even though the JWT has a 24h exp. Consider either setting cookie expiration in CreateCookie to match deadlineHours, or adjusting the comment/behavior to avoid confusion.

Suggested change
deadlineHours: 24, // 1日有効
deadlineHours: 24, // JWTは1日有効(Cookie自体はセッション有効)

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants