@@ -65,10 +65,12 @@ def _auth_user_info_from_token_data(token_data: dict[str, _typing.Any]):
65
65
def _auth_user_metadata_from_token_data (token_data : dict [str , _typing .Any ]):
66
66
from firebase_functions .identity_fn import AuthUserMetadata
67
67
creation_time = int (token_data ["creation_time" ]) / 1000.0
68
- last_sign_in_time = int (token_data ["last_sign_in_time" ]) / 1000.0
68
+ last_sign_in_time = None
69
+ if "last_sign_in_time" in token_data :
70
+ last_sign_in_time = int (token_data ["last_sign_in_time" ]) / 1000.0
69
71
return AuthUserMetadata (
70
72
creation_time = _dt .datetime .utcfromtimestamp (creation_time ),
71
- last_sign_in_time = _dt .datetime .utcfromtimestamp (last_sign_in_time ),
73
+ last_sign_in_time = _dt .datetime .utcfromtimestamp (last_sign_in_time ) if last_sign_in_time else None ,
72
74
)
73
75
74
76
@@ -89,7 +91,7 @@ def _auth_multi_factor_info_from_token_data(token_data: dict[str, _typing.Any]):
89
91
90
92
91
93
def _auth_multi_factor_settings_from_token_data (token_data : dict [str ,
92
- _typing .Any ]):
94
+ _typing .Any ]):
93
95
if not token_data :
94
96
return None
95
97
@@ -214,14 +216,14 @@ def _auth_blocking_event_from_token_data(token_data: dict[str, _typing.Any]):
214
216
215
217
216
218
def _validate_auth_response (
217
- event_type : str ,
218
- auth_response ,
219
+ event_type : str ,
220
+ auth_response ,
219
221
) -> dict [str , _typing .Any ]:
220
222
if auth_response is None :
221
223
auth_response = {}
222
224
223
225
custom_claims : dict [str ,
224
- _typing .Any ] | None = auth_response .get ("custom_claims" )
226
+ _typing .Any ] | None = auth_response .get ("custom_claims" )
225
227
session_claims : dict [str , _typing .Any ] | None = auth_response .get (
226
228
"session_claims" )
227
229
@@ -303,9 +305,9 @@ def _validate_auth_response(
303
305
304
306
305
307
def before_operation_handler (
306
- func : _typing .Callable ,
307
- event_type : str ,
308
- request : _Request ,
308
+ func : _typing .Callable ,
309
+ event_type : str ,
310
+ request : _Request ,
309
311
) -> _Response :
310
312
from firebase_functions .identity_fn import BeforeCreateResponse , BeforeSignInResponse
311
313
try :
0 commit comments