avoid merge conflict
parent
747daab4cb
commit
273ab4cdab
|
@ -1,154 +1,97 @@
|
||||||
from decouple import config
|
from decouple import config
|
||||||
|
|
||||||
|
|
||||||
MYEMS_SYSTEM_DB_HOST = config('MYEMS_SYSTEM_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_SYSTEM_DB_PORT = config('MYEMS_SYSTEM_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_SYSTEM_DB_DATABASE = config('MYEMS_SYSTEM_DB_DATABASE', default='myems_system_db')
|
|
||||||
MYEMS_SYSTEM_DB_USER = config('MYEMS_SYSTEM_DB_USER', default='root')
|
|
||||||
MYEMS_SYSTEM_DB_PASSWORD = config('MYEMS_SYSTEM_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_ENERGY_DB_HOST = config('MYEMS_ENERGY_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_ENERGY_DB_PORT = config('MYEMS_ENERGY_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_ENERGY_DB_DATABASE = config('MYEMS_ENERGY_DB_DATABASE', default='myems_energy_db')
|
|
||||||
MYEMS_ENERGY_DB_USER = config('MYEMS_ENERGY_DB_USER', default='root')
|
|
||||||
MYEMS_ENERGY_DB_PASSWORD = config('MYEMS_ENERGY_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_ENERGY_BASELINE_DB_HOST = config('MYEMS_ENERGY_BASELINE_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_ENERGY_BASELINE_DB_PORT = config('MYEMS_ENERGY_BASELINE_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_ENERGY_BASELINE_DB_DATABASE = config('MYEMS_ENERGY_BASELINE_DB_DATABASE', default='myems_energy_baseline_db')
|
|
||||||
MYEMS_ENERGY_BASELINE_DB_USER = config('MYEMS_ENERGY_BASELINE_DB_USER', default='root')
|
|
||||||
MYEMS_ENERGY_BASELINE_DB_PASSWORD = config('MYEMS_ENERGY_BASELINE_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_BILLING_DB_HOST = config('MYEMS_BILLING_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_BILLING_DB_PORT = config('MYEMS_BILLING_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_BILLING_DB_DATABASE = config('MYEMS_BILLING_DB_DATABASE', default='myems_billing_db')
|
|
||||||
MYEMS_BILLING_DB_USER = config('MYEMS_BILLING_DB_USER', default='root')
|
|
||||||
MYEMS_BILLING_DB_PASSWORD = config('MYEMS_BILLING_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_BILLING_BASELINE_DB_HOST = config('MYEMS_BILLING_BASELINE_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_BILLING_BASELINE_DB_PORT = config('MYEMS_BILLING_BASELINE_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_BILLING_BASELINE_DB_DATABASE = config('MYEMS_BILLING_BASELINE_DB_DATABASE', default='myems_billing_baseline_db')
|
|
||||||
MYEMS_BILLING_BASELINE_DB_USER = config('MYEMS_BILLING_BASELINE_DB_USER', default='root')
|
|
||||||
MYEMS_BILLING_BASELINE_DB_PASSWORD = config('MYEMS_BILLING_BASELINE_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_HISTORICAL_DB_HOST = config('MYEMS_HISTORICAL_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_HISTORICAL_DB_PORT = config('MYEMS_HISTORICAL_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_HISTORICAL_DB_DATABASE = config('MYEMS_HISTORICAL_DB_DATABASE', default='myems_historical_db')
|
|
||||||
MYEMS_HISTORICAL_DB_USER = config('MYEMS_HISTORICAL_DB_USER', default='root')
|
|
||||||
MYEMS_HISTORICAL_DB_PASSWORD = config('MYEMS_HISTORICAL_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_USER_DB_HOST = config('MYEMS_USER_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_USER_DB_PORT = config('MYEMS_USER_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_USER_DB_DATABASE = config('MYEMS_USER_DB_DATABASE', default='myems_user_db')
|
|
||||||
MYEMS_USER_DB_USER = config('MYEMS_USER_DB_USER', default='root')
|
|
||||||
MYEMS_USER_DB_PASSWORD = config('MYEMS_USER_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_FDD_DB_HOST = config('MYEMS_FDD_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_FDD_DB_PORT = config('MYEMS_FDD_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_FDD_DB_DATABASE = config('MYEMS_FDD_DB_DATABASE', default='myems_fdd_db')
|
|
||||||
MYEMS_FDD_DB_USER = config('MYEMS_FDD_DB_USER', default='root')
|
|
||||||
MYEMS_FDD_DB_PASSWORD = config('MYEMS_FDD_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MYEMS_REPORTING_DB_HOST = config('MYEMS_REPORTING_DB_HOST', default='127.0.0.1')
|
|
||||||
MYEMS_REPORTING_DB_PORT = config('MYEMS_REPORTING_DB_PORT', default=3306, cast=int)
|
|
||||||
MYEMS_REPORTING_DB_DATABASE = config('MYEMS_REPORTING_DB_DATABASE', default='myems_reporting_db')
|
|
||||||
MYEMS_REPORTING_DB_USER = config('MYEMS_REPORTING_DB_USER', default='root')
|
|
||||||
MYEMS_REPORTING_DB_PASSWORD = config('MYEMS_REPORTING_DB_PASSWORD', default='!MyEMS1')
|
|
||||||
|
|
||||||
MINUTES_TO_COUNT = config('MINUTES_TO_COUNT', default=60, cast=int)
|
|
||||||
UTC_OFFSET = config('UTC_OFFSET', default='+08:00')
|
|
||||||
WORKING_DAY_START_TIME_LOCAL = config('WORKING_DAY_START_TIME_LOCAL', default='00:00:00')
|
|
||||||
UPLOAD_PATH = config('UPLOAD_PATH', default='/var/www/html/admin/upload/')
|
|
||||||
CURRENCY_UNIT = config('CURRENCY_UNIT', default='CNY')
|
|
||||||
|
|
||||||
myems_system_db = {
|
myems_system_db = {
|
||||||
'host': MYEMS_SYSTEM_DB_HOST,
|
'host': config('MYEMS_SYSTEM_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_SYSTEM_DB_PORT,
|
'port': config('MYEMS_SYSTEM_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_SYSTEM_DB_DATABASE,
|
'database': config('MYEMS_SYSTEM_DB_DATABASE', default='myems_system_db'),
|
||||||
'user': MYEMS_SYSTEM_DB_USER,
|
'user': config('MYEMS_SYSTEM_DB_USER', default='root'),
|
||||||
'password': MYEMS_SYSTEM_DB_PASSWORD,
|
'password': config('MYEMS_SYSTEM_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_energy_db = {
|
myems_energy_db = {
|
||||||
'host': MYEMS_ENERGY_DB_HOST,
|
'host': config('MYEMS_ENERGY_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_ENERGY_DB_PORT,
|
'port': config('MYEMS_ENERGY_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_ENERGY_DB_DATABASE,
|
'database': config('MYEMS_ENERGY_DB_DATABASE', default='myems_energy_db'),
|
||||||
'user': MYEMS_ENERGY_DB_USER,
|
'user': config('MYEMS_ENERGY_DB_USER', default='root'),
|
||||||
'password': MYEMS_ENERGY_DB_PASSWORD,
|
'password': config('MYEMS_ENERGY_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_energy_baseline_db = {
|
myems_energy_baseline_db = {
|
||||||
'host': MYEMS_ENERGY_BASELINE_DB_HOST,
|
'host': config('MYEMS_ENERGY_BASELINE_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_ENERGY_BASELINE_DB_PORT,
|
'port': config('MYEMS_ENERGY_BASELINE_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_ENERGY_BASELINE_DB_DATABASE,
|
'database': config('MYEMS_ENERGY_BASELINE_DB_DATABASE', default='myems_energy_baseline_db'),
|
||||||
'user': MYEMS_ENERGY_BASELINE_DB_USER,
|
'user': config('MYEMS_ENERGY_BASELINE_DB_USER', default='root'),
|
||||||
'password': MYEMS_ENERGY_BASELINE_DB_PASSWORD,
|
'password': config('MYEMS_ENERGY_BASELINE_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_billing_db = {
|
myems_billing_db = {
|
||||||
'host': MYEMS_BILLING_DB_HOST,
|
'host': config('MYEMS_BILLING_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_BILLING_DB_PORT,
|
'port': config('MYEMS_BILLING_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_BILLING_DB_DATABASE,
|
'database': config('MYEMS_BILLING_DB_DATABASE', default='myems_billing_db'),
|
||||||
'user': MYEMS_BILLING_DB_USER,
|
'user': config('MYEMS_BILLING_DB_USER', default='root'),
|
||||||
'password': MYEMS_BILLING_DB_PASSWORD,
|
'password': config('MYEMS_BILLING_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_billing_baseline_db = {
|
myems_billing_baseline_db = {
|
||||||
'host': MYEMS_BILLING_BASELINE_DB_HOST,
|
'host': config('MYEMS_BILLING_BASELINE_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_BILLING_BASELINE_DB_PORT,
|
'port': config('MYEMS_BILLING_BASELINE_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_BILLING_BASELINE_DB_DATABASE,
|
'database': config('MYEMS_BILLING_BASELINE_DB_DATABASE', default='myems_billing_baseline_db'),
|
||||||
'user': MYEMS_BILLING_BASELINE_DB_USER,
|
'user': config('MYEMS_BILLING_BASELINE_DB_USER', default='root'),
|
||||||
'password': MYEMS_BILLING_BASELINE_DB_PASSWORD,
|
'password': config('MYEMS_BILLING_BASELINE_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_historical_db = {
|
myems_historical_db = {
|
||||||
'host': MYEMS_HISTORICAL_DB_HOST,
|
'host': config('MYEMS_HISTORICAL_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_HISTORICAL_DB_PORT,
|
'port': config('MYEMS_HISTORICAL_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_HISTORICAL_DB_DATABASE,
|
'database': config('MYEMS_HISTORICAL_DB_DATABASE', default='myems_historical_db'),
|
||||||
'user': MYEMS_HISTORICAL_DB_USER,
|
'user': config('MYEMS_HISTORICAL_DB_USER', default='root'),
|
||||||
'password': MYEMS_HISTORICAL_DB_PASSWORD,
|
'password': config('MYEMS_HISTORICAL_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_user_db = {
|
myems_user_db = {
|
||||||
'host': MYEMS_USER_DB_HOST,
|
'host': config('MYEMS_USER_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_USER_DB_PORT,
|
'port': config('MYEMS_USER_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_USER_DB_DATABASE,
|
'database': config('MYEMS_USER_DB_DATABASE', default='myems_user_db'),
|
||||||
'user': MYEMS_USER_DB_USER,
|
'user': config('MYEMS_USER_DB_USER', default='root'),
|
||||||
'password': MYEMS_USER_DB_PASSWORD,
|
'password': config('MYEMS_USER_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_fdd_db = {
|
myems_fdd_db = {
|
||||||
'host': MYEMS_FDD_DB_HOST,
|
'host': config('MYEMS_FDD_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_FDD_DB_PORT,
|
'port': config('MYEMS_FDD_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_FDD_DB_DATABASE,
|
'database': config('MYEMS_FDD_DB_DATABASE', default='myems_fdd_db'),
|
||||||
'user': MYEMS_FDD_DB_USER,
|
'user': config('MYEMS_FDD_DB_USER', default='root'),
|
||||||
'password': MYEMS_FDD_DB_PASSWORD,
|
'password': config('MYEMS_FDD_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
myems_reporting_db = {
|
myems_reporting_db = {
|
||||||
'host': MYEMS_REPORTING_DB_HOST,
|
'host': config('MYEMS_REPORTING_DB_HOST', default='127.0.0.1'),
|
||||||
'port': MYEMS_REPORTING_DB_PORT,
|
'port': config('MYEMS_REPORTING_DB_PORT', default=3306, cast=int),
|
||||||
'database': MYEMS_REPORTING_DB_DATABASE,
|
'database': config('MYEMS_REPORTING_DB_DATABASE', default='myems_reporting_db'),
|
||||||
'user': MYEMS_REPORTING_DB_USER,
|
'user': config('MYEMS_REPORTING_DB_USER', default='root'),
|
||||||
'password': MYEMS_REPORTING_DB_PASSWORD,
|
'password': config('MYEMS_REPORTING_DB_PASSWORD', default='!MyEMS1'),
|
||||||
}
|
}
|
||||||
|
|
||||||
# indicated in how many minutes to calculate meter energy consumption
|
# indicated in how many minutes to calculate meter energy consumption
|
||||||
# 30 for half hourly period
|
# 30 for half hourly period
|
||||||
# 60 for hourly period
|
# 60 for hourly period
|
||||||
minutes_to_count = MINUTES_TO_COUNT
|
minutes_to_count = config('MINUTES_TO_COUNT', default=60, cast=int)
|
||||||
|
|
||||||
# indicates the project's time zone offset from UTC
|
# indicates the project's time zone offset from UTC
|
||||||
utc_offset = UTC_OFFSET
|
utc_offset = config('UTC_OFFSET', default='+08:00')
|
||||||
|
|
||||||
# indicates from when ( in local timezone) of the day to calculate working days
|
# indicates from when ( in local timezone) of the day to calculate working days
|
||||||
working_day_start_time_local = WORKING_DAY_START_TIME_LOCAL
|
working_day_start_time_local = config('WORKING_DAY_START_TIME_LOCAL', default='00:00:00')
|
||||||
|
|
||||||
# indicates where user uploaded files will be saved to
|
# indicates where user uploaded files will be saved to
|
||||||
# must use the root folder of myems-admin web application
|
# must use the root folder of myems-admin web application
|
||||||
# for example if you serve myems-admin at /var/www/html/admin
|
# for example if you serve myems-admin at /var/www/html/admin
|
||||||
# you should set the upload_path as below
|
# you should set the upload_path as below
|
||||||
upload_path = UPLOAD_PATH
|
upload_path = config('UPLOAD_PATH', default='/var/www/html/admin/upload/')
|
||||||
|
|
||||||
# main currency unit
|
# main currency unit
|
||||||
currency_unit = CURRENCY_UNIT
|
currency_unit = config('CURRENCY_UNIT', default='CNY')
|
||||||
|
|
||||||
|
# maximum failed login count, otherwise the user should be locked
|
||||||
|
maximum_failed_login_count = config('MAXIMUM_FAILED_LOGIN_COUNT', default=3, cast=int)
|
|
@ -27,7 +27,7 @@ class UserCollection:
|
||||||
cursor = cnx.cursor()
|
cursor = cnx.cursor()
|
||||||
query = (" SELECT u.id, u.name, u.display_name, u.uuid, "
|
query = (" SELECT u.id, u.name, u.display_name, u.uuid, "
|
||||||
" u.email, u.is_admin, p.id, p.name, "
|
" u.email, u.is_admin, p.id, p.name, "
|
||||||
" u.account_expiration_datetime_utc, u.password_expiration_datetime_utc "
|
" u.account_expiration_datetime_utc, u.password_expiration_datetime_utc, u.failed_login_count "
|
||||||
" FROM tbl_users u "
|
" FROM tbl_users u "
|
||||||
" LEFT JOIN tbl_privileges p ON u.privilege_id = p.id "
|
" LEFT JOIN tbl_privileges p ON u.privilege_id = p.id "
|
||||||
" ORDER BY u.name ")
|
" ORDER BY u.name ")
|
||||||
|
@ -59,7 +59,8 @@ class UserCollection:
|
||||||
"account_expiration_datetime":
|
"account_expiration_datetime":
|
||||||
account_expiration_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
account_expiration_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||||
"password_expiration_datetime":
|
"password_expiration_datetime":
|
||||||
password_expiration_datetime_local.strftime('%Y-%m-%dT%H:%M:%S')}
|
password_expiration_datetime_local.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||||
|
"failed_login_count": row[10]}
|
||||||
result.append(meta_result)
|
result.append(meta_result)
|
||||||
|
|
||||||
resp.text = json.dumps(result)
|
resp.text = json.dumps(result)
|
||||||
|
@ -503,7 +504,7 @@ class UserLogin:
|
||||||
|
|
||||||
failed_login_count = result['failed_login_count']
|
failed_login_count = result['failed_login_count']
|
||||||
|
|
||||||
if failed_login_count >= 3:
|
if failed_login_count >= config.maximum_failed_login_count:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.USER_ACCOUNT_HAS_BEEN_LOCKED')
|
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.USER_ACCOUNT_HAS_BEEN_LOCKED')
|
||||||
|
@ -523,6 +524,14 @@ class UserLogin:
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.INVALID_PASSWORD')
|
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.INVALID_PASSWORD')
|
||||||
|
|
||||||
|
if failed_login_count != 0:
|
||||||
|
update_failed_login_count = (" UPDATE tbl_users "
|
||||||
|
" SET failed_login_count = 0 "
|
||||||
|
" WHERE uuid = %s ")
|
||||||
|
user_uuid = result['uuid']
|
||||||
|
cursor.execute(update_failed_login_count, (user_uuid, ))
|
||||||
|
cnx.commit()
|
||||||
|
|
||||||
if result['account_expiration_datetime_utc'] <= datetime.utcnow():
|
if result['account_expiration_datetime_utc'] <= datetime.utcnow():
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
|
@ -886,7 +895,7 @@ class Unlock:
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.INVALID_Id')
|
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.INVALID_Id')
|
||||||
|
|
||||||
failed_login_count = row[0]
|
failed_login_count = row[0]
|
||||||
if failed_login_count < 3:
|
if failed_login_count < config.maximum_failed_login_count:
|
||||||
cursor.close()
|
cursor.close()
|
||||||
cnx.disconnect()
|
cnx.disconnect()
|
||||||
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.USER_ACCOUNT_IS_NOT_LOCKED')
|
raise falcon.HTTPError(falcon.HTTP_400, 'API.BAD_REQUEST', 'API.USER_ACCOUNT_IS_NOT_LOCKED')
|
||||||
|
|
Loading…
Reference in New Issue