(add, done): add email smtp service and auth service done!

This commit is contained in:
behruz-dev
2025-08-26 11:20:41 +05:00
parent 8feea731b9
commit b46b9975ba
13 changed files with 199 additions and 16 deletions

View File

@@ -2,21 +2,21 @@ import redis
r = redis.StrictRedis.from_url('redis://redis:6379')
def cache_user_credentials(email, password, passport_id, pnlf, time):
def cache_user_credentials(email, password, passport_id, pnfl, time):
key = f"user_credentials:{email}"
r.hmset(key, {
r.hset(key, mapping={
"email": email,
"password": password,
"passport_id": passport_id,
"pnlf": pnlf,
"pnfl": pnfl,
})
r.expire(key, time)
def get_user_credentials(email):
key = f"user_credentials:{email}"
data = r.hgetall(key)
if not data:
return None
@@ -25,6 +25,29 @@ def get_user_credentials(email):
"email": data.get(b'email').decode() if data.get(b'email') else None,
"password": data.get(b'password').decode() if data.get(b'password') else None,
"passport_id": data.get(b'passport_id').decode() if data.get(b'passport_id') else None,
"pnlf": data.get(b'pnlf').decode() if data.get(b'pnlf') else None,
"pnfl": data.get(b'pnfl').decode() if data.get(b'pnfl') else None,
}
def cache_user_confirmation_code(code, email, time):
key = f"user_confirmation:{email}_{code}"
r.hset(key, mapping={
'email': email,
'code': code
})
r.expire(key, time)
def get_user_confirmation_code(email, code):
key = f'user_confirmation:{email}_{code}'
data = r.hgetall(key)
if not data:
return None
return {
"email": data.get(b'email').decode() if data.get(b'email') else None,
"code": data.get(b'code').decode() if data.get(b'code') else None
}