@@ -42,19 +42,39 @@ def __init__(self, config, account_handler):
42
42
logger .info ('Endpoint: %s' , self .endpoint )
43
43
logger .info ('Enforce lowercase username during registration: %s' , self .regLower )
44
44
45
+ account_handler .register_password_auth_provider_callbacks (
46
+ auth_checkers = {
47
+ ("m.login.password" , ("password" ,)): self .check_pass ,
48
+ },
49
+ check_3pid_auth = {
50
+ self .check_3pid_auth
51
+ }
52
+ )
53
+
45
54
async def check_3pid_auth (self , medium , address , password ):
46
55
logger .info ("Got password check for " + address )
47
56
if medium != "email" :
48
57
reason = "Medium is not email. Unsuported medium for login using the rest-password-provider. Only username and email is supported."
49
58
logger .warning (reason )
50
59
return None
51
60
login_result = await self .check_password (user_id = address ,password = password )
52
- if not login_result :
61
+ if login_result :
62
+ return self .account_handler .get_qualified_user_id (address ), None
63
+ return None
64
+
65
+ async def check_pass (
66
+ self ,
67
+ username : str ,
68
+ login_type : str ,
69
+ login_dict : "synapse.module_api.JsonDict" ,
70
+ ):
71
+ if login_type != "m.login.password" :
53
72
return None
54
- return address
55
-
56
- async def on_logged_out (self , user_id , device_id , access_token ):
57
- return True
73
+ matrix_user_id = self .account_handler .get_qualified_user_id (username )
74
+ is_valid = await self .check_password (matrix_user_id ,login_dict .get ("password" ))
75
+ if is_valid :
76
+ return matrix_user_id , None
77
+ return None
58
78
59
79
async def check_password (self , user_id , password ):
60
80
logger .info ("Got password check for " + user_id )
0 commit comments