def test_token(self): user = UserFactory() token = create_callback_token_for_user(user, "email") response = self.client.get("{}?{}={}".format( reverse("tokens:login"), settings.EMAIL_AUTH_TOKEN_NAME, token, )) self.assertEquals(response.status_code, status.HTTP_302_FOUND)
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 = custom_send_sms_with_callback_token # Send to alias success = send_action(user, token, **message_payload) return success
def send_token(to_alias, alias_type, token_type, **message_payload): token = create_callback_token_for_user(to_alias, alias_type, token_type) send_action = None if alias_type == 'email': send_action = import_string(api_settings.PASSWORDLESS_EMAIL_CALLBACK) elif alias_type == 'mobile': send_action = import_string(api_settings.PASSWORDLESS_SMS_CALLBACK) # Send to alias success = send_action(to_alias, token, **message_payload) return success
def send_token(user, alias_type, token_type, **message_payload): token = create_callback_token_for_user(user, alias_type, token_type) send_action = None if alias_type == 'email': send_action = import_string( api_settings.PASSWORDLESS_AUTH_EMAIL_SEND_FUNCTION) elif alias_type == 'mobile': send_action = import_string( api_settings.PASSWORDLESS_AUTH_MOBILE_SEND_FUNCTION) # Send to alias success = send_action(user, token, **message_payload) return success
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 if user.country == 'fi' and user.mobile is not None: send_sms_with_callback_token(user, token, **message_payload) elif alias_type == 'mobile': send_action = send_sms_with_callback_token # Send to alias success = send_action(user, token, **message_payload) return success
def send_token(user, alias_type, token_type, **message_payload): token = create_callback_token_for_user(user, alias_type, token_type) send_action = None if alias_type == 'email': send_action = send_email_with_callback_token elif alias_type == 'mobile': sms_action_name = api_settings.PASSWORDLESS_SMS_ACTION.split('.') module_name = '.'.join(sms_action_name[:-1]) try: sms_action_module = importlib.import_module(module_name) except ModuleNotFoundError: send_action = send_sms_with_callback_token else: send_action = getattr(sms_action_module, sms_action_name[-1]) # Send to alias success = send_action(user, token, **message_payload) return success
def update_url_with_auth_token(url, user): token = create_callback_token_for_user(user, 'email') return update_url_with_kwargs(url, **{settings.EMAIL_AUTH_TOKEN_NAME: token})
def get_token_auth_link(user): token = create_callback_token_for_user(user, 'email') return update_url_with_kwargs(urljoin(site_url(), reverse('email_auth:login')), token=token)