For an extension, I am attempting to return a `NotFound` object as a response to an ajax call made on the frontend. This `NotFound` class inherits from the `TectonResponse` class, just like the `Success` , `BadRequest` , and `InternalServerError` classes. The issue that I am running into is that I am receiving an error when I attempt to return a `NotFound` object that reads: `q2_sdk.core.exceptions.InvalidReturnType: Ajax target method must return a dictionary or TectonResponse` . The relevant code that I am using is below:
```
from q2_sdk.models.tecton import TectonResponse, Success, NotFound, BadRequest, InternalServerError
@ajax
async def unlock_credentials(self) -> TectonResponse:
user_logon: UserLogonRow
user: UserRow
does_user_data_match_login = False
passed_ssn = str(self.form_fields.get('ssn'))
passed_last_name = (str(self.form_fields.get('lastName'))).rstrip()
passed_dob = str(self.form_fields.get('dob'))
passed_login_id = (str(self.form_fields.get('loginId'))).rstrip()
try:
user_logon = await self.db.user_logon.get_login_by_name(passed_login_id)
except Exception as ex:
return InternalServerError("An error was encountered.")
if not user_logon:
return NotFound() # NotFound call here
for logon in user_logon:
try:
if await self.is_existing_user_data(logon.UserID, passed_ssn, passed_last_name, passed_dob) is True:
does_user_data_match_login = True
user = (await self.db.user.get(logon.UserID))[0]
except Exception as ex:
return InternalServerError("An error was encountered.")
if does_user_data_match_login is False:
return NotFound() # NotFound call here
if self.is_user_disabled(user) is False:
response = await self.db.user_logon.unlock(passed_login_id)
return Success()
else:
return BadRequest(f"You are not authorized to unlock the provided login ID, '{passed_login_id}'.")
```
I am running the latest version of the SDK and the latest version of Tecton. I cannot find why my `NotFound` objects are not treated as `TectonResponses` during ajax calls.
For an extension, I am attempting to return a `NotFound` object as a response to an ajax call made on the frontend. This `NotFound` class inherits from the `TectonResponse` class, just like the `Success` , `BadRequest` , and `InternalServerError` classes. The issue that I am running into is that I am receiving an error when I attempt to return a `NotFound` object that reads: `q2_sdk.core.exceptions.InvalidReturnType: Ajax target method must return a dictionary or TectonResponse` . The relevant code that I am using is below:
```
from q2_sdk.models.tecton import TectonResponse, Success, NotFound, BadRequest, InternalServerError
@ajax
async def unlock_credentials(self) -> TectonResponse:
user_logon: UserLogonRow
user: UserRow
does_user_data_match_login = False
passed_ssn = str(self.form_fields.get('ssn'))
passed_last_name = (str(self.form_fields.get('lastName'))).rstrip()
passed_dob = str(self.form_fields.get('dob'))
passed_login_id = (str(self.form_fields.get('loginId'))).rstrip()
try:
user_logon = await self.db.user_logon.get_login_by_name(passed_login_id)
except Exception as ex:
return InternalServerError("An error was encountered.")
if not user_logon:
return NotFound() # NotFound call here
for logon in user_logon:
try:
if await self.is_existing_user_data(logon.UserID, passed_ssn, passed_last_name, passed_dob) is True:
does_user_data_match_login = True
user = (await self.db.user.get(logon.UserID))[0]
except Exception as ex:
return InternalServerError("An error was encountered.")
if does_user_data_match_login is False:
return NotFound() # NotFound call here
if self.is_user_disabled(user) is False:
response = await self.db.user_logon.unlock(passed_login_id)
return Success()
else:
return BadRequest(f"You are not authorized to unlock the provided login ID, '{passed_login_id}'.")
```
I am running the latest version of the SDK and the latest version of Tecton. I cannot find why my NotFound objects are not treated as TectonResponses during ajax calls.
For an extension, I am attempting to return a `NotFound` object as a response to an ajax call made on the frontend. This `NotFound` class inherits from the `TectonResponse` class, just like the `Success` , `BadRequest` , and `InternalServerError` classes. The issue that I am running into is that I am receiving an error when I attempt to return a `NotFound` object that reads: `q2_sdk.core.exceptions.InvalidReturnType: Ajax target method must return a dictionary or TectonResponse` . The relevant code that I am using is below:
```
from q2_sdk.models.tecton import TectonResponse, Success, NotFound, BadRequest, InternalServerError
@ajax
async def unlock_credentials(self) -> TectonResponse:
user_logon: UserLogonRow
user: UserRow
does_user_data_match_login = False
passed_ssn = str(self.form_fields.get('ssn'))
passed_last_name = (str(self.form_fields.get('lastName'))).rstrip()
passed_dob = str(self.form_fields.get('dob'))
passed_login_id = (str(self.form_fields.get('loginId'))).rstrip()
try:
user_logon = await self.db.user_logon.get_login_by_name(passed_login_id)
except Exception as ex:
return InternalServerError("An error was encountered.")
if not user_logon:
return NotFound() # NotFound call here
for logon in user_logon:
try:
if await self.is_existing_user_data(logon.UserID, passed_ssn, passed_last_name, passed_dob) is True:
does_user_data_match_login = True
user = (await self.db.user.get(logon.UserID))[0]
except Exception as ex:
return InternalServerError("An error was encountered.")
if does_user_data_match_login is False:
return NotFound() # NotFound call here
if self.is_user_disabled(user) is False:
response = await self.db.user_logon.unlock(passed_login_id)
return Success()
else:
return BadRequest(f"You are not authorized to unlock the provided login ID, '{passed_login_id}'.")
```
I am running the latest version of the SDK and the latest version of Tecton. I cannot find why my NotFound objects are not treated as TectonResponses during ajax calls.
For an extension, I am attempting to return a `NotFound` object as a response to an ajax call made on the frontend. This `NotFound` class inherits from the `TectonResponse` class, just like the `Success` , `BadRequest` , and `InternalServerError` classes. The issue that I am running into is that I am receiving an error when I attempt to return a `NotFound` object that reads: `q2_sdk.core.exceptions.InvalidReturnType: Ajax target method must return a dictionary or TectonResponse` . The relevant code that I am using is below:
```
@ajax
async def unlock_credentials(self) -> TectonResponse:
user_logon: UserLogonRow
user: UserRow
does_user_data_match_login = False
passed_ssn = str(self.form_fields.get('ssn'))
passed_last_name = (str(self.form_fields.get('lastName'))).rstrip()
passed_dob = str(self.form_fields.get('dob'))
passed_login_id = (str(self.form_fields.get('loginId'))).rstrip()
try:
user_logon = await self.db.user_logon.get_login_by_name(passed_login_id)
except Exception as ex:
self.logger.error(f"An error was encountered getting the user logon row for the login name '{passed_login_id}'.")
self.logger.error(ex)
return InternalServerError("An error was encountered.")
if not user_logon:
self.logger.info(f"The login name passed from the client, '{passed_login_id}', does not match a record in our database.")
return NotFound() # NotFound call here
for logon in user_logon:
try:
if await self.is_existing_user_data(logon.UserID, passed_ssn, passed_last_name, passed_dob) is True:
does_user_data_match_login = True
user = (await self.db.user.get(logon.UserID))[0]
break
except Exception as ex:
self.logger.error(f"An error was encountered validating User data for the login name '{passed_login_id}'.")
self.logger.error(ex)
return InternalServerError("An error was encountered.")
if does_user_data_match_login is False:
self.logger.info(f"The user information passed along with the login name '{passed_login_id}' does not match our records.")
return NotFound() # NotFound call here
if self.is_user_disabled(user) is False:
response = await self.db.user_logon.unlock(passed_login_id)
return Success()
else:
self.logger.info(f"The member with the login name '{passed_login_id}' is locked at the User level. They will not be unlocked at the Login level.")
return BadRequest(f"You are not authorized to unlock the provided login ID, '{passed_login_id}'.")
```
I am running the latest version of the SDK and the latest version of Tecton. I cannot find why my NotFound objects are not treated as TectonResponses during ajax calls.
Why are NotFound objects not treated as TectonResponse objects?
For an extension, I am attempting to return a `NotFound` object as a response to an ajax call made on the frontend. This `NotFound` class inherits from the `TectonResponse` class, just like the `Success` , `BadRequest` , and `InternalServerError` classes. The issue that I am running into is that I am receiving an error when I attempt to return a `NotFound` object that reads: `q2_sdk.core.exceptions.InvalidReturnType: Ajax target method must return a dictionary or TectonResponse` . The relevant code that I am using is below:
```
@ajax
async def unlock_credentials(self) -> TectonResponse:
user_logon: UserLogonRow
user: UserRow
does_user_data_match_login = False
passed_ssn = str(self.form_fields.get('ssn'))
passed_last_name = (str(self.form_fields.get('lastName'))).rstrip()
passed_dob = str(self.form_fields.get('dob'))
passed_login_id = (str(self.form_fields.get('loginId'))).rstrip()
try:
user_logon = await self.db.user_logon.get_login_by_name(passed_login_id)
except Exception as ex:
self.logger.error(f"An error was encountered getting the user logon row for the login name '{passed_login_id}'.")
self.logger.error(ex)
return InternalServerError("An error was encountered.")
if not user_logon:
self.logger.info(f"The login name passed from the client, '{passed_login_id}', does not match a record in our database.")
return NotFound() # NotFound call here
for logon in user_logon:
try:
if await self.is_existing_user_data(logon.UserID, passed_ssn, passed_last_name, passed_dob) is True:
does_user_data_match_login = True
user = (await self.db.user.get(logon.UserID))[0]
break
except Exception as ex:
self.logger.error(f"An error was encountered validating User data for the login name '{passed_login_id}'.")
self.logger.error(ex)
return InternalServerError("An error was encountered.")
if does_user_data_match_login is False:
self.logger.info(f"The user information passed along with the login name '{passed_login_id}' does not match our records.")
return NotFound() # NotFound call here
if self.is_user_disabled(user) is False:
response = await self.db.user_logon.unlock(passed_login_id)
return Success()
else:
self.logger.info(f"The member with the login name '{passed_login_id}' is locked at the User level. They will not be unlocked at the Login level.")
return BadRequest(f"You are not authorized to unlock the provided login ID, '{passed_login_id}'.")
```
I am running the latest version of the SDK and the latest version of Tecton. I cannot find why my NotFound objects are not treated as TectonResponses during ajax calls.