skip kick prompt if IRC server reported a connection drop and no further requests are sent (sans webui)
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				Build / build (18) (push) Successful in 42s
				
			
		
			
				
	
				Build / build (20) (push) Successful in 59s
				
			
		
			
				
	
				Build / build (22) (push) Successful in 1m7s
				
			
		
			
				
	
				Build / build (18) (pull_request) Successful in 41s
				
			
		
			
				
	
				Build / build (20) (pull_request) Successful in 58s
				
			
		
			
				
	
				Build / build (22) (pull_request) Successful in 1m6s
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	Build / build (18) (push) Successful in 42s
				
			Build / build (20) (push) Successful in 59s
				
			Build / build (22) (push) Successful in 1m7s
				
			Build / build (18) (pull_request) Successful in 41s
				
			Build / build (20) (pull_request) Successful in 58s
				
			Build / build (22) (pull_request) Successful in 1m6s
				
			This commit is contained in:
		
							parent
							
								
									eedb9e3137
								
							
						
					
					
						commit
						1d7e99bd17
					
				@ -65,7 +65,7 @@ export const loginController: RequestHandler = async (request, response) => {
 | 
			
		||||
            account.Nonce = nonce;
 | 
			
		||||
        }
 | 
			
		||||
    } else {
 | 
			
		||||
        if (account.Nonce && account.ClientType != "webui" && !loginRequest.kick) {
 | 
			
		||||
        if (account.Nonce && account.ClientType != "webui" && !account.Dropped && !loginRequest.kick) {
 | 
			
		||||
            response.status(400).json({ error: "nonce still set" });
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										9
									
								
								src/controllers/custom/ircDroppedController.ts
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										9
									
								
								src/controllers/custom/ircDroppedController.ts
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,9 @@
 | 
			
		||||
import { getAccountForRequest } from "@/src/services/loginService";
 | 
			
		||||
import { RequestHandler } from "express";
 | 
			
		||||
 | 
			
		||||
export const ircDroppedController: RequestHandler = async (req, res) => {
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    account.Dropped = true;
 | 
			
		||||
    await account.save();
 | 
			
		||||
    res.end();
 | 
			
		||||
};
 | 
			
		||||
@ -20,6 +20,7 @@ const databaseAccountSchema = new Schema<IDatabaseAccountJson>(
 | 
			
		||||
        ConsentNeeded: { type: Boolean, required: true },
 | 
			
		||||
        TrackedSettings: { type: [String], default: [] },
 | 
			
		||||
        Nonce: { type: Number, default: 0 },
 | 
			
		||||
        Dropped: Boolean,
 | 
			
		||||
        LastLoginDay: { type: Number },
 | 
			
		||||
        LatestEventMessageDate: { type: Date, default: 0 }
 | 
			
		||||
    },
 | 
			
		||||
 | 
			
		||||
@ -7,6 +7,7 @@ import { popArchonCrystalUpgradeController } from "@/src/controllers/custom/popA
 | 
			
		||||
import { deleteAccountController } from "@/src/controllers/custom/deleteAccountController";
 | 
			
		||||
import { getNameController } from "@/src/controllers/custom/getNameController";
 | 
			
		||||
import { renameAccountController } from "@/src/controllers/custom/renameAccountController";
 | 
			
		||||
import { ircDroppedController } from "@/src/controllers/custom/ircDroppedController";
 | 
			
		||||
 | 
			
		||||
import { createAccountController } from "@/src/controllers/custom/createAccountController";
 | 
			
		||||
import { createMessageController } from "@/src/controllers/custom/createMessageController";
 | 
			
		||||
@ -28,6 +29,7 @@ customRouter.get("/popArchonCrystalUpgrade", popArchonCrystalUpgradeController);
 | 
			
		||||
customRouter.get("/deleteAccount", deleteAccountController);
 | 
			
		||||
customRouter.get("/getName", getNameController);
 | 
			
		||||
customRouter.get("/renameAccount", renameAccountController);
 | 
			
		||||
customRouter.get("/ircDropped", ircDroppedController);
 | 
			
		||||
 | 
			
		||||
customRouter.post("/createAccount", createAccountController);
 | 
			
		||||
customRouter.post("/createMessage", createMessageController);
 | 
			
		||||
 | 
			
		||||
@ -82,21 +82,12 @@ export const getAccountForRequest = async (req: Request): Promise<TAccountDocume
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const getAccountIdForRequest = async (req: Request): Promise<string> => {
 | 
			
		||||
    if (!req.query.accountId) {
 | 
			
		||||
        throw new Error("Request is missing accountId parameter");
 | 
			
		||||
    const account = await getAccountForRequest(req);
 | 
			
		||||
    if (account.Dropped && req.query.ct) {
 | 
			
		||||
        account.Dropped = undefined;
 | 
			
		||||
        await account.save();
 | 
			
		||||
    }
 | 
			
		||||
    if (!req.query.nonce || parseInt(req.query.nonce as string) === 0) {
 | 
			
		||||
        throw new Error("Request is missing nonce parameter");
 | 
			
		||||
    }
 | 
			
		||||
    if (
 | 
			
		||||
        !(await Account.exists({
 | 
			
		||||
            _id: req.query.accountId,
 | 
			
		||||
            Nonce: req.query.nonce
 | 
			
		||||
        }))
 | 
			
		||||
    ) {
 | 
			
		||||
        throw new Error("Invalid accountId-nonce pair");
 | 
			
		||||
    }
 | 
			
		||||
    return req.query.accountId as string;
 | 
			
		||||
    return account._id.toString();
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
export const isAdministrator = (account: TAccountDocument): boolean => {
 | 
			
		||||
 | 
			
		||||
@ -14,6 +14,7 @@ export interface IAccountAndLoginResponseCommons {
 | 
			
		||||
export interface IDatabaseAccount extends IAccountAndLoginResponseCommons {
 | 
			
		||||
    email: string;
 | 
			
		||||
    password: string;
 | 
			
		||||
    Dropped?: boolean;
 | 
			
		||||
    LastLoginDay?: number;
 | 
			
		||||
    LatestEventMessageDate: Date;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user