def save(self, domain=None, email_template=None, email_subject=None, email_sender=None, commit=True): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(NameEmailUserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting('HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) # password1 = self.cleaned_data.get('password1') # user.set_password(password1) if commit: user.save() # associate user and email from htk.apps.accounts.utils import associate_user_email associate_user_email( user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender ) # mark has_username_set user_profile = user.profile user_profile.has_username_set = True user_profile.save() # send welcome email was_activated = user.is_active if was_activated: user_profile.send_welcome_email() return user
def _process_registration(self, domain, email_template, email_subject, email_sender, commit): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(UserRegistrationForm, self).save(commit=False) # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting('HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email if not htk_setting('HTK_ACCOUNT_ACTIVATE_UPON_REGISTRATION', False): # require user to confirm email account before activating it user.is_active = False if commit: user.save() from htk.apps.accounts.utils import associate_user_email associate_user_email( user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender ) return user
def associate_email(strategy, details, user, social, *args, **kwargs): """Associate email with the user """ if not user or not social: return None response = None email = details.get('email') domain = strategy.request.get_host() # Should confirm if the email was provided by the social auth provider, not the user # i.e. SOCIAL_REGISTRATION_SETTING_MISSING_EMAIL was False confirmed = not (strategy.request.session.get( SOCIAL_REGISTRATION_SETTING_MISSING_EMAIL, False)) user_email = associate_user_email(user, email, domain=domain, confirmed=confirmed) if user_email: # need to update the User with the activated one, so that it doesn't get overwritten later on response = { 'user': user_email.user, } return response
def save(self, domain=None, email_template=None, email_subject=None, email_sender=None, commit=True): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(NameEmailUserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting('HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) #password1 = self.cleaned_data.get('password1') #user.set_password(password1) if commit: user.save() # associate user and email from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender) # mark has_username_set user_profile = user.profile user_profile.has_username_set = True user_profile.save() # send welcome email was_activated = user.is_active if was_activated: user_profile.send_welcome_email() return user
def save(self, domain=None, commit=True): user = self.user domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user_email = None if user: email = self.email user_email = associate_user_email(user, email, domain=domain) return user_email
def save(self, domain=None, commit=True): user = self.user domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user_email = None if user: email = self.email user_email = associate_user_email(user, email, domain) return user_email
def _get_user_session_with_primary_email(self): """Returns an authenticated user, its primary email, password, and authenticated client """ (user, password, client,) = self._get_user_session() from htk.apps.accounts.utils import associate_user_email email = create_test_email() user_email = associate_user_email(user, email, confirmed=True) user_email.set_primary_email() return (user, email, password, client,)
def _get_user_session_with_primary_email(self): """Returns an authenticated user, its primary email, password, and authenticated client """ (user, password, client,) = self._get_user_session() from htk.apps.accounts.utils import associate_user_email email = create_test_email() user_email = associate_user_email(user, email, confirmed=True) user_email.set_primary_email() return (user, email, password, client,)
def save(self, domain=DEFAULT_EMAIL_SENDING_DOMAIN, commit=True): user = super(UserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email user.primary_email = email # require user to confirm email account before activating it user.is_active = False if commit: user.save() user_email = associate_user_email(user, email, domain) return user
def save(self, domain=None, commit=True): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(UserRegistrationForm, self).save(commit=False) email = self.email # temporarily assign a unique username so that we can create the record and the user can log in user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email if not htk_setting('HTK_ACCOUNT_ACTIVATE_UPON_REGISTRATION', False): # require user to confirm email account before activating it user.is_active = False if commit: user.save() from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain) return user
def _process_registration(self, domain, email_template, email_subject, email_sender, commit): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(UserRegistrationForm, self).save(commit=False) # temporarily assign a unique username so that we can create the record and the user can log in if htk_setting('HTK_ACCOUNTS_REGISTER_SET_PRETTY_USERNAME_FROM_EMAIL', False): user.username = email_to_username_pretty_unique(email) else: user.username = email_to_username_hash(email) # we'll store the primary email in the User object user.email = email if not htk_setting('HTK_ACCOUNT_ACTIVATE_UPON_REGISTRATION', False): # require user to confirm email account before activating it user.is_active = False if commit: user.save() from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain=domain, email_template=email_template, email_subject=email_subject, email_sender=email_sender) return user
def associate_email(request, details, user, social, *args, **kwargs): """Associate email with the user """ if not user or not social: return None response = None email = details.get('email') domain = request.get_host() # Should confirm if the email was provided by the social auth provider, not the user # i.e. SOCIAL_REGISTRATION_SETTING_MISSING_EMAIL was False confirmed = not(request.session.get(SOCIAL_REGISTRATION_SETTING_MISSING_EMAIL, False)) user_email = associate_user_email(user, email, domain, confirmed=confirmed) if user_email: # need to update the User with the activated one, so that it doesn't get overwritten later on response = { 'user': user_email.user, } return response
def save(self, domain=None, commit=True): domain = domain or htk_setting('HTK_DEFAULT_EMAIL_SENDING_DOMAIN') user = super(NameEmailUserRegistrationForm, self).save(commit=False) email = self.email user.username = email_to_username_pretty_unique(email) #password1 = self.cleaned_data.get('password1') #user.set_password(password1) if commit: user.save() # associate user and email from htk.apps.accounts.utils import associate_user_email user_email = associate_user_email(user, email, domain) # mark has_username_set user_profile = user.profile user_profile.has_username_set = True user_profile.save() # send welcome email was_activated = user.is_active if was_activated: user_profile.send_welcome_email() return user
def save(self, user=None, domain=DEFAULT_EMAIL_SENDING_DOMAIN, commit=True): user_email = None if user: email = self.email user_email = associate_user_email(user, email, domain) return user_email