-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinterfaces.py
62 lines (48 loc) · 1.51 KB
/
interfaces.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
from abc import ABC, abstractmethod
from typing import Dict, List, Optional
from datetime import datetime
class DatabaseInterface(ABC):
@abstractmethod
def find_user_by_email(self, email: str) -> Optional[Dict]:
pass
@abstractmethod
def find_user_by_id(self, user_id: str) -> Optional[Dict]:
pass
@abstractmethod
def save_user(self, user, password_hash: str) -> None:
pass
@abstractmethod
def update_user(self, user) -> None:
pass
@abstractmethod
def get_password_hash(self, user_id: str) -> Optional[str]:
pass
@abstractmethod
def update_password(self, user_id: str, password_hash: str) -> None:
pass
@abstractmethod
def get_user_activity_logs(self, user_id: str) -> List[Dict]:
pass
class CacheInterface(ABC):
@abstractmethod
def set_user_data(self, user_id: str, data: Dict) -> None:
pass
@abstractmethod
def get_user_data(self, user_id: str) -> Dict:
pass
@abstractmethod
def increment_login_attempts(self, user_id: str) -> None:
pass
@abstractmethod
def clear_login_attempts(self, user_id: str) -> None:
pass
class EmailServiceInterface(ABC):
@abstractmethod
def send_welcome_email(self, email: str) -> None:
pass
@abstractmethod
def send_password_reset_email(self, email: str, temp_password: str) -> None:
pass
@abstractmethod
def send_role_update_email(self, email: str, new_role: str) -> None:
pass