@@ -135,6 +135,8 @@ def __init__(self, fetch_user):
135135 ),
136136 Rule ("/__engine/1.1/functions/_User/onLogin" , endpoint = "on_login" ),
137137 Rule ("/__engine/1/functions/_User/onLogin" , endpoint = "on_login" ),
138+ Rule ("/__engine/1.1/functions/_User/onAuthData" , endpoint = "on_auth_data" ),
139+ Rule ("/__engine/1/functions/_User/onAuthData" , endpoint = "on_auth_data" ),
138140 Rule (
139141 "/__engine/1/functions/<class_name>/<hook_name>" ,
140142 endpoint = "cloud_hook" ,
@@ -163,6 +165,8 @@ def __init__(self, fetch_user):
163165 Rule ("/1.1/functions/BigQuery/<event>" , endpoint = "on_bigquery" ),
164166 Rule ("/1.1/functions/_User/onLogin" , endpoint = "on_login" ),
165167 Rule ("/1/functions/_User/onLogin" , endpoint = "on_login" ),
168+ Rule ("/1.1/functions/_User/onAuthData" , endpoint = "on_auth_data" ),
169+ Rule ("/1/functions/_User/onAuthData" , endpoint = "on_auth_data" ),
166170 Rule ("/1/functions/<class_name>/<hook_name>" , endpoint = "cloud_hook" ),
167171 Rule ("/1.1/functions/<class_name>/<hook_name>" , endpoint = "cloud_hook" ),
168172 Rule ("/1/functions/onVerified/<verify_type>" , endpoint = "on_verified" ),
@@ -247,6 +251,10 @@ def dispatch_request(self, environ):
247251 result = {
248252 "result" : dispatch_on_login (self .cloud_codes , app_params , ** values )
249253 }
254+ elif endpoint == "on_auth_data" :
255+ result = {
256+ "result" : dispatch_on_auth_data (self .cloud_codes , app_params , ** values )
257+ }
250258 elif endpoint == "ops_meta_data" :
251259 from .authorization import MASTER_KEY
252260
@@ -508,6 +516,26 @@ def dispatch_on_login(_cloud_codes, app_params, params):
508516
509517 return func (user )
510518
519+ def register_on_auth_data (_cloud_codes , func ):
520+ func_name = "__on_auth_data__User"
521+
522+ if func_name in _cloud_codes :
523+ raise RuntimeError ("on authdata is already registered" )
524+ _cloud_codes [func_name ] = func
525+
526+ def dispatch_on_auth_data (_cloud_codes , app_params , params ):
527+ from .authorization import HOOK_KEY
528+ current_hook_key = app_params .get ("hook_key" )
529+ if not current_hook_key or current_hook_key != HOOK_KEY :
530+ raise LeanEngineError (code = 401 , message = "Unauthorized." )
531+
532+ func = _cloud_codes .get ("__on_auth_data__User" )
533+ if not func :
534+ return
535+
536+ auth_data = params ["object" ]
537+ return func (auth_data )
538+
511539
512540def dispatch_ops_meta_data (_cloud_codes ):
513541 return list (_cloud_codes .keys ())
0 commit comments