From 1cafe0c8ddf35817dac552e4d63c0992e16548d6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 25 Oct 2019 13:52:07 +0100 Subject: [PATCH] Tidying --- daemon.py | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/daemon.py b/daemon.py index c7b104f2..36175755 100644 --- a/daemon.py +++ b/daemon.py @@ -2834,15 +2834,14 @@ class PubServer(BaseHTTPRequestHandler): print('Login success: '+loginNickname) self.send_response(303) # This produces a deterministic token based on nick+password+salt - if not self.server.salts.get(loginNickname): - saltFilename=self.server.baseDir+'/accounts/'+loginNickname+'@'+self.server.domain+'/.salt' - if os.path.isfile(saltFilename): - with open(saltFilename, 'r') as fp: - self.server.salts[loginNickname] = fp.read() - else: - self.server.salts[loginNickname]=createPassword(32) - with open(saltFilename, 'w') as fp: - fp.write(self.server.salts[loginNickname]) + saltFilename=self.server.baseDir+'/accounts/'+loginNickname+'@'+self.server.domain+'/.salt' + if os.path.isfile(saltFilename): + with open(saltFilename, 'r') as fp: + self.server.salts[loginNickname] = fp.read() + else: + self.server.salts[loginNickname]=createPassword(32) + with open(saltFilename, 'w') as fp: + fp.write(self.server.salts[loginNickname]) self.server.tokens[loginNickname]=sha256((loginNickname+loginPassword+self.server.salts[loginNickname]).encode('utf-8')).hexdigest() self.server.tokensLookup[self.server.tokens[loginNickname]]=loginNickname self.send_header('Set-Cookie', 'epicyon='+self.server.tokens[loginNickname]+'; SameSite=Strict')