mirror of https://gitlab.com/bashrc2/epicyon
Convert password removal to function
parent
e18ea5dcbd
commit
36e83d174f
10
auth.py
10
auth.py
|
@ -114,6 +114,16 @@ def storeBasicCredentials(baseDir: str,nickname: str,password: str) -> bool:
|
||||||
passfile.write(storeStr+'\n')
|
passfile.write(storeStr+'\n')
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def removePassword(baseDir: str,nickname: str) -> None:
|
||||||
|
passwordFile=baseDir+'/accounts/passwords'
|
||||||
|
if os.path.isfile(passwordFile):
|
||||||
|
with open(passwordFile, "r") as fin:
|
||||||
|
with open(passwordFile+'.new', "w") as fout:
|
||||||
|
for line in fin:
|
||||||
|
if not line.startswith(nickname+':'):
|
||||||
|
fout.write(line)
|
||||||
|
os.rename(passwordFile+'.new', passwordFile)
|
||||||
|
|
||||||
def authorize(baseDir: str,path: str,authHeader: str,debug: bool) -> bool:
|
def authorize(baseDir: str,path: str,authHeader: str,debug: bool) -> bool:
|
||||||
if authHeader.lower().startswith('basic '):
|
if authHeader.lower().startswith('basic '):
|
||||||
return authorizeBasic(baseDir,path,authHeader,debug)
|
return authorizeBasic(baseDir,path,authHeader,debug)
|
||||||
|
|
11
epicyon.py
11
epicyon.py
|
@ -39,6 +39,7 @@ from tests import runAllTests
|
||||||
from config import setConfigParam
|
from config import setConfigParam
|
||||||
from config import getConfigParam
|
from config import getConfigParam
|
||||||
from auth import storeBasicCredentials
|
from auth import storeBasicCredentials
|
||||||
|
from auth import removePassword
|
||||||
import argparse
|
import argparse
|
||||||
|
|
||||||
def str2bool(v):
|
def str2bool(v):
|
||||||
|
@ -186,15 +187,7 @@ if args.rmaccount:
|
||||||
sys.exit()
|
sys.exit()
|
||||||
handle=nickname+'@'+domain
|
handle=nickname+'@'+domain
|
||||||
accountRemoved=False
|
accountRemoved=False
|
||||||
passwordFile=baseDir+'/accounts/passwords'
|
removePassword(baseDir,nickname)
|
||||||
if os.path.isfile(passwordFile):
|
|
||||||
# remove from passwords file
|
|
||||||
with open(passwordFile, "r") as fin:
|
|
||||||
with open(passwordFile+'.new', "w") as fout:
|
|
||||||
for line in fin:
|
|
||||||
if not line.startswith(nickname+':'):
|
|
||||||
fout.write(line)
|
|
||||||
os.rename(passwordFile+'.new', passwordFile)
|
|
||||||
if os.path.isdir(baseDir+'/accounts/'+handle):
|
if os.path.isdir(baseDir+'/accounts/'+handle):
|
||||||
shutil.rmtree(baseDir+'/accounts/'+handle)
|
shutil.rmtree(baseDir+'/accounts/'+handle)
|
||||||
accountRemoved=True
|
accountRemoved=True
|
||||||
|
|
Loading…
Reference in New Issue