def generate_account(self, user): account = Account(key=tools.generate_key()) account.save() user_profile = UserProfile( user=user, account=account ) user_profile.save() send_mail( 'Rmd.io account confirmation', """ Hello, please click this link to activate your rmd.io account: {0}/registration_done/{1} Sincerely, The rmd.io Team """.format( settings.SITE_URL, str(account.key, 'utf-8') ), settings.EMAIL_HOST_USER, [user.email], fail_silently=False, )
def create_additional_user(email, user): """Creates an additional user with the same password and identity :param email: the email address of the new user :type email: string :param user: the user which wants to create a new user :type email: django.contrib.auth.models.User """ from mails.models import UserProfile, AddressLog new_user = User( email=email, username=base64.urlsafe_b64encode(sha1( smart_bytes(email)).digest()).decode("utf-8").rstrip("="), date_joined=timezone.now(), password=user.password, is_active=False, ) new_user.save() account = user.get_account() user_profile = UserProfile(user=new_user, account=account) user_profile.save() try: user_log_entry = AddressLog.objects.filter(email=user.email) user_log_entry.delete() except: pass key = base64.urlsafe_b64encode( new_user.username.encode("utf-8")).decode("utf-8") send_activation_mail(recipient=email, key=key)
def generate_account(self, user): account = Account(key=tools.generate_key()) account.save() user_profile = UserProfile(user=user, account=account) user_profile.save() send_mail( 'Rmd.io account confirmation', """ Hello, please click this link to activate your rmd.io account: http://rmd.io/registration_done/{} Sincerely, The rmd.io Team """.format(account.key), '*****@*****.**', [user.email], fail_silently=False, )