Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Merge pull request #24 from NfoAlex/FixTooMuchInformation
Browse files Browse the repository at this point in the history
Fix too much information
  • Loading branch information
NfoAlex authored Jun 16, 2023
2 parents 3e206e0 + 40b80ab commit d2db938
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 15 deletions.
7 changes: 4 additions & 3 deletions auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ let authUserByCookie = function authUserByCookie(sessionid) {
let registerUser = function registerUser(dat) { //dat=[0=>name(名前), 1=>key(招待コード)]
//招待制だったらコードを確認
if ( db.dataServer.registration.invite.inviteOnly && db.dataServer.registration.available ) { //招待制かどうか
if ( db.dataServer.registration.invite.inviteCode !== dat[1] ) { //招待コードが一致しているかどうか
console.log("registerUser :: 招待コード違うわ");
//招待コードが一致しているかどうか
if ( db.dataServer.registration.invite.inviteCode !== dat[1] ) {
console.log("auth :: registerUser : 招待コード違うわ");
return -1;

}
console.log("registerUser :: 招待コード合ってる!");
console.log("auth :: registerUser : 招待コード合ってる!");

}

Expand Down
2 changes: 1 addition & 1 deletion dbControl.js
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ let getModlog = async function getModlog(dat) {
}

//サーバーの設定情報を取得
let getInfoServer = function getServerSettings() {
let getInfoServer = function getInfoServer() {
//サーバー情報を構成
let ServerSettings = {
servername: dataServer.servername,
Expand Down
51 changes: 45 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ io.on("connection", (socket) => {
//サーバー設定の更新
socket.on("changeServerSettings", (dat) => {
/*
dat
servername: "xxx",
config: this.displaySettings.config,
registration: {
available: this.displaySettings.registerAvailable,
invite: {
Expand All @@ -305,8 +306,15 @@ io.on("connection", (socket) => {
let serverSettings = db.getInfoServer(dat);
serverSettings.serverVersion = SERVER_VERSION;

//現在のサーバー設定を全員に送信
io.emit("infoServer", serverSettings);
//現在のサーバー設定を更新した人に返す
io.to("loggedin").emit("infoServerFull", serverSettings);

let serverSettingsEdited = structuredClone(serverSettings);

//ログイン前の人向けに招待コードと設定を削除して全員に送信
delete serverSettingsEdited.registration.invite.inviteCode;
delete serverSettingsEdited.config;
io.emit("infoServer", serverSettingsEdited);

});

Expand Down Expand Up @@ -876,7 +884,7 @@ io.on("connection", (socket) => {

//新規登録
socket.on("register", (dat) => {
console.log("register :: 登録しようとしてる");
console.log("register :: 登録しようとしてる", dat);
let key = auth.registerUser(dat); //DBにユーザーを登録、パスワードの取得

//返り値が-1じゃないなら
Expand Down Expand Up @@ -1216,14 +1224,45 @@ io.on("connection", (socket) => {

});

//サーバー情報の送信
//サーバー情報の送信(ゲスト、一般ユーザー用)
socket.on("getInfoServer", () => {
//サーバー情報格納用
let serverSettings = {};

//あらかじめサーバー情報を取得
serverSettings = db.getInfoServer(); //情報収集
serverSettings.serverVersion = SERVER_VERSION; //バージョン情報をつける

//JSONをいじるため完全にコピー
let serverSettingsEdited = structuredClone(serverSettings);

//招待コードと設定データを削除
delete serverSettingsEdited.registration.invite.inviteCode;

//送信
socket.emit("infoServer", serverSettingsEdited);

});

//サーバー初期情報の送信(管理者用)
socket.on("getInfoServerFull", (dat) => {
try {
//権限と整合性チェック
if (
!checkDataIntegrality(dat, [], "getInfoServerFull") &&
db.dataServer.user[dat.reqSender.userid].role !== "Admin"
) {
return -1;

}
} catch(e) {}

//セッションが適合か確認
serverSettings = db.getInfoServer(); //情報収集
serverSettings.serverVersion = SERVER_VERSION; //バージョン情報をつける

//情報送信
socket.emit("infoServer", serverSettings);
socket.emit("infoServerFull", serverSettings);

});

Expand Down
9 changes: 4 additions & 5 deletions infoUpdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,18 +190,15 @@ let mod = function mod(dat) {
//サーバーの設定を更新
let changeServerSettings = function changeServerSettings(dat) {
/*
dat
servername: "aaa",
servername: "xxx",
config: this.displaySettings.config,
registration: {
available: this.displaySettings.registerAvailable,
invite: {
inviteOnly: this.displaySettings.inviteOnly,
inviteCode: this.displaySettings.inviteCode
}
},
config: {
...
},
reqSender: {
userid: Userinfo.userid,
sessionid: Userinfo.sessionid
Expand All @@ -226,6 +223,8 @@ let changeServerSettings = function changeServerSettings(dat) {
//インスタンス設定をマージ
db.dataServer.config = {...db.dataServer.config, ...dat.config};

console.log("infoUpdate :: changeServerSettings : マージ元データ->", dat.registration);

//監査ログへの記録処理
recordModeration(
dat.reqSender.userid,
Expand Down

0 comments on commit d2db938

Please sign in to comment.