<reponame>appealing-alexey/ew
#!/usr/bin/env python
import json
import sys

def readConf():
    c = open('cgi-bin/config.json', 'r').read()
    o = json.loads(c)
    return o

def incorrectPassword():
    res = {'status':'Error', 'message':'Incorrect password.'}
    print json.dumps(res)
    sys.exit()

def changePassword():
    res = {'status':'Error', 'message':'Currently the default password is set. Change the password to something more secure.'}
    print json.dumps(res)
    sys.exit()

def validPassword(sentPassword):
    conf = readConf()
    storedPassword = conf.get('password', '<PASSWORD>')
    if isDefaultPassword(sentPassword) or sentPassword != storedPassword: return False
    return True

def isDefaultPassword(sentPassword):
    return sentPassword == '<PASSWORD>'

#!/usr/bin/env python
import json
import sys

def readConf():
    c = open('cgi-bin/config.json', 'r').read()
    o = json.loads(c)
    return o

def incorrectPassword():
    res = {'status':'Error', 'message':'Incorrect password.'}
    print json.dumps(res)
    sys.exit()

def changePassword():
    res = {'status':'Error', 'message':'Currently the default password is set. Change the password to something more secure.'}
    print json.dumps(res)
    sys.exit()

def validPassword(sentPassword):
    conf = readConf()
    storedPassword = conf.get('password', '<PASSWORD>')
    if isDefaultPassword(sentPassword) or sentPassword != storedPassword: return False
    return True

def isDefaultPassword(sentPassword):
    return sentPassword == '<PASSWORD>'
#!/usr/bin/env python