Development
This commit is contained in:
parent
025adb9f15
commit
5b1f905ed0
7 changed files with 38 additions and 47 deletions
|
|
@ -43,16 +43,6 @@ def _send_verification_email(to_address, code):
|
|||
smtp.send_message(msg)
|
||||
|
||||
|
||||
def _tz_to_offset_seconds(tz_str):
|
||||
try:
|
||||
from zoneinfo import ZoneInfo
|
||||
from datetime import datetime
|
||||
return int(datetime.now(ZoneInfo(tz_str)).utcoffset().total_seconds())
|
||||
except Exception:
|
||||
import settings as _s
|
||||
return _s.get_host_utc_offset()
|
||||
|
||||
|
||||
@bp.route('/action/accountcreate/form_create', methods=['POST'])
|
||||
@auth.require_level('nothing')
|
||||
def form_create():
|
||||
|
|
@ -88,8 +78,7 @@ def form_create():
|
|||
|
||||
salt = bcrypt.gensalt()
|
||||
hashed = bcrypt.hashpw(password.encode('utf-8'), salt).decode('utf-8')
|
||||
code = f'{secrets.randbelow(1000000):06d}'
|
||||
tz_offset = _tz_to_offset_seconds(tz)
|
||||
code = f'{secrets.randbelow(1000000):06d}'
|
||||
|
||||
try:
|
||||
_send_verification_email(account['email_address'], code)
|
||||
|
|
@ -101,15 +90,15 @@ def form_create():
|
|||
con = config_utils.open_accounts_db()
|
||||
con.execute(
|
||||
'''INSERT INTO clients
|
||||
(cookie_unique_token, email, hashed_password, tz_offset_seconds, verification_code, code_sent_ts)
|
||||
(cookie_unique_token, email, hashed_password, timezone, verification_code, code_sent_ts)
|
||||
VALUES (?,?,?,?,?,?)
|
||||
ON CONFLICT(cookie_unique_token) DO UPDATE SET
|
||||
email=excluded.email,
|
||||
hashed_password=excluded.hashed_password,
|
||||
tz_offset_seconds=excluded.tz_offset_seconds,
|
||||
timezone=excluded.timezone,
|
||||
verification_code=excluded.verification_code,
|
||||
code_sent_ts=excluded.code_sent_ts''',
|
||||
(session.sid, account['email_address'].lower(), hashed, tz_offset, code, int(time.time()))
|
||||
(session.sid, account['email_address'].lower(), hashed, tz, code, int(time.time()))
|
||||
)
|
||||
con.commit()
|
||||
con.close()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue