mirror of
https://github.com/clusterio/clusterio.git
synced 2026-11-12 07:04:52 +09:00
Fix handleFetchPlayerCodeRequest returning incorrect properties
This commit is contained in:
1 parent
5ae19042f1
commit
cafafbd540
2 files changed
+6
-6
No files matched your search
@@ -176,7 +176,7 @@ export class ControllerPlugin extends BaseControllerPlugin {
|
||||
let playerCode = await generateCode(this.controller.config.get("player_auth.code_length"));
|
||||
let expiresMs = Date.now() + this.controller.config.get("player_auth.code_timeout") * 1000;
|
||||
this.players.set(request.player, { playerCode, verifyCode: null, expiresMs });
|
||||
return { player_code: playerCode, controller_url: this.controller.getControllerUrl() };
|
||||
return { playerCode, controllerUrl: this.controller.getControllerUrl() };
|
||||
}
|
||||
|
||||
async handleSetVerifyCodeRequest(request: SetVerifyCodeRequest) {
|
||||
|
||||
@@ -300,8 +300,8 @@ describe("player_auth", function() {
|
||||
let result = await controllerPlugin.handleFetchPlayerCodeRequest(
|
||||
new FetchPlayerCodeRequest("test")
|
||||
);
|
||||
assert(typeof result.player_code === "string", "no code returned");
|
||||
assert(result.player_code.length === 10, "incorrect code length returned");
|
||||
assert(typeof result.playerCode === "string", "no code returned");
|
||||
assert(result.playerCode.length === 10, "incorrect code length returned");
|
||||
let expiresMs = controllerPlugin.players.get("test").expiresMs;
|
||||
let msFromExpected = Math.abs(expiresMs - Date.now() - 1000);
|
||||
assert(msFromExpected < 100, `expiry time expected outside window (${msFromExpected}ms)`);
|
||||
@@ -332,14 +332,14 @@ describe("player_auth", function() {
|
||||
describe("integration", function() {
|
||||
it("should verify a full login flow", async function() {
|
||||
let app = controllerPlugin.controller.app;
|
||||
let { player_code } = await controllerPlugin.handleFetchPlayerCodeRequest(
|
||||
let { playerCode } = await controllerPlugin.handleFetchPlayerCodeRequest(
|
||||
new FetchPlayerCodeRequest("test")
|
||||
);
|
||||
|
||||
let playerCodeResult = await phin({
|
||||
url: `${controllerUrl}/api/player_auth/player_code`,
|
||||
method: "POST",
|
||||
data: { player_code },
|
||||
data: { player_code: playerCode },
|
||||
parse: "json",
|
||||
});
|
||||
|
||||
@@ -351,7 +351,7 @@ describe("player_auth", function() {
|
||||
let verifyResult = await phin({
|
||||
url: `${controllerUrl}/api/player_auth/verify`,
|
||||
method: "POST",
|
||||
data: { player_code, verify_code, verify_token },
|
||||
data: { player_code: playerCode, verify_code, verify_token },
|
||||
parse: "json",
|
||||
});
|
||||
assert.equal(verifyResult.body.verified, true);
|
||||
|
||||
Reference in new issue
Block a user