mirror of
https://github.com/i701/sarlink-portal-api.git
synced 2025-04-30 13:55:41 +00:00
Some checks failed
Build and Push Docker Images / Build and Push Docker Images (push) Failing after 4m12s
- Updated the `reverse_dhivehi_string` function to correct the range for combining characters. - Added new device handling in the health check view and integrated the `add_new_devices_to_omada` task. - Improved date handling in `CreateTemporaryUserView` to ensure proper string conversion. - Enhanced OTP sending by converting mobile numbers to strings. - Implemented MAC address validation in the `Device` model using a custom validator. - Removed unnecessary fields from the `CreateDeviceSerializer`. - Normalized MAC address format in the `DeviceListCreateAPIView`. - Updated the `djangopasswordlessknox` package to improve code consistency and readability. - Added migration to enforce MAC address validation in the database.
24 lines
740 B
Python
24 lines
740 B
Python
from djangopasswordlessknox.utils import (
|
|
create_callback_token_for_user,
|
|
send_email_with_callback_token,
|
|
send_sms_with_callback_token,
|
|
)
|
|
|
|
|
|
class TokenService(object):
|
|
@staticmethod
|
|
def send_token(user, alias_type, **message_payload):
|
|
token = create_callback_token_for_user(user, alias_type)
|
|
send_action = None
|
|
if alias_type == "email":
|
|
send_action = send_email_with_callback_token
|
|
elif alias_type == "mobile":
|
|
send_action = send_sms_with_callback_token
|
|
|
|
if send_action is None:
|
|
raise ValueError(f"Invalid alias_type: {alias_type}")
|
|
|
|
# Send to alias
|
|
success = send_action(user, token, **message_payload)
|
|
return success
|