def save(self, request): adapter = get_adapter() user = adapter.new_user(request) adapter.save_user(request, user, self) setup_user_email(request, user, []) self.signup(user) return user
def pre_social_login(self, request, sociallogin): email = sociallogin.user.email try: user = User.objects.get(email=email) except User.DoesNotExist: user = None emails_query = EmailAddress.objects.filter(email=email) if not user and emails_query.exists(): user = emails_query[0].user if user: sociallogin.user = user if sociallogin.is_existing: # Social Account already connected, signin please _login_social_account(request, sociallogin) else: sociallogin.account.user = user sociallogin.account.save() if sociallogin.token: sociallogin.token.account = sociallogin.account sociallogin.token.save() if not EmailAddress.objects.filter(user=user).exists(): setup_user_email(request, user, sociallogin.email_addresses)
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) adapter.save_user(request, user, self) self.custom_signup(request, user) # TODO: Move into adapter `save_user` ? setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.clean_password(self.cleaned_data['password1'], user) adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) # Enforce the username to be the email self.cleaned_data['username'] = \ self.cleaned_data['email'] adapter.save_user(request, user, self) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.save() Vender.objects.create(user=user) return user
def save(self, request): """Called by perform_create().""" # adapter = get_adapter() self.cleaned_data = self.get_cleaned_data() user = self.new_user(request) # adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() user.child_name = request.data.get('child_name') adapter.save_user(request, user, self) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter(request) user = adapter.new_user(request) user.age = self.cleaned_data['age'] user.sex = self.cleaned_data['sex'] adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.home = self.cleaned_data.get('home') user.save() return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) user.phone = self.get_cleaned_data().get('phone') self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): self.cleaned_data = self.get_cleaned_data() user = UserModel.objects.create_user( phone=self.cleaned_data.get('phone'), password=self.cleaned_data.get('password1'), email=self.cleaned_data.get('email')) user.save() setup_user_email(request, user, []) return user
def save(self, request): if request.user.is_anonymous or request.user.password: # anon or normal user return super().save(request) else: # ghost request.user.username = request.data['username'] request.user.email = request.data['email'] request.user.set_password(request.data['password1']) request.user.save() setup_user_email(request, request.user, []) return request.user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.allow_send_email = self.cleaned_data['allow_send_email'] user.set_password(self.cleaned_data['password']) user.save() return user
def save(self, request): self.cleaned_data = self.validated_data # Needed by new_user() user = get_account_adapter().new_user(request) original_request = request._request get_account_adapter().save_user(request, user, self) setup_user_email(request, user, []) complete_signup(original_request, user, allauth_settings.EMAIL_VERIFICATION, None) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() user.first_name = self.cleaned_data['first_name'] user.last_name = self.cleaned_data['last_name'] adapter.save_user(request, user, self) setup_user_email(request, user, []) user.save() return user
def save(self, request): assert not self.is_existing user = self.account.user user.save() self.account.user = user self.account.save() if self.token: self.token.account = self.account self.token.save() setup_user_email(request, user, self.email_addresses)
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() user.username = self.cleaned_data['email'].split('@')[0] + getRandomStringSubFix() user.telNumber = self.cleaned_data['telNumber'] adapter.save_user(request, user, self) setup_user_email(request, user, []) # user.profile.save() return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() # commit=False does not save the user to the DB yet adapter.save_user(request, user, self, commit=False) # the custom_signup method contains the openwisp specific logic self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() user.is_Service_provider = self.cleaned_data['is_Service_provider'] adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) user.is_Service_provider = self.cleaned_data['is_Service_provider'] return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.is_buyer = self.cleaned_data['is_buyer'] user.is_seller = self.cleaned_data['is_seller'] user.save() return user
def save(self, **kwargs): request = self.context.get('request') self.validated_data['password'] = make_password(self.validated_data.pop('password1')) del self.validated_data['password2'] if self.validated_data.get('captcha'): del self.validated_data['captcha'] user = User.objects.create(**self.validated_data, is_active=False) setup_user_email(request=request, user=user, addresses=[]) # CeleryService.send_email_confirm(user) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) user.first_name = request.data['name'] user.save() return user
def create(self, validated_data): user = User( email=validated_data.get('email'), first_name=validated_data.get('first_name'), ) user.set_password(validated_data.get('password')) user.save() request = self._get_request() setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter(request) user = adapter.new_user(request) adapter.save_user(request, user, self) user.display_name = self.cleaned_data['display_name'] user.save() self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): new_user = self.create_user() self.sociallogin.account.user = new_user self.sociallogin.save(request) super(SignupForm, self).save(new_user) # Make sure the user has a primary email address if EmailAddress.objects.filter(user=new_user).count() == 0: setup_user_email(request, new_user) # Confirmation last (save may alter first_name etc -- used in mail) send_email_confirmation(request, new_user) return new_user
def save(self, request): adapter = get_adapter() print(request) user = adapter.new_user(request) print(user.username) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter(request) user = adapter.new_user(request) adapter.save_user(request, user, self) user.type_of_person = self.cleaned_data['type_of_person'] user.save() self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) # self.custom_signup(request, user) setup_user_email(request, user, []) # user.name = self.cleaned_data.get('name') # user.surname = self.cleaned_data.get('surname') user.save() return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.address = self.cleaned_data.get('address') user.date_of_birth = self.cleaned_data.get('date_of_birth') user.phone_number = self.cleaned_data.get('phone_number') user.save() return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) Usuario.objects.create( user=user, rol="Usuario", institucion=self.cleaned_data.get("institucion")) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) print(self.cleaned_data) user.name = self.cleaned_data.get('name', '') user.profile_image = self.cleaned_data.get('profile_image', '') user.save() return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() # mdclub user-specific properties user.create_time = user.date_joined.timestamp() # save adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.donante.genero = self.cleaned_data['genero'] user.is_active = False user.save() enviar_mail_activacion(user) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) users_count = User.objects.all().values("pk").count() user.phone = users_count + 1 self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) setup_user_email(request, user, []) user.save() get_first_location(request, user) return user
def save(self, request): adapter = get_adapter() user = adapter.new_user(request) self.cleaned_data = self.get_cleaned_data() adapter.save_user(request, user, self) self.custom_signup(request, user) setup_user_email(request, user, []) user.is_driver = self.cleaned_data.get('is_driver') user.is_customer = self.cleaned_data.get('is_customer') user.player_id = self.cleaned_data.get('player_id') user.phone = self.cleaned_data.get('phone') user.address = self.cleaned_data.get('address') user.mobile_phone = self.cleaned_data.get('mobile_phone') user.save() return user
def invite_artist(self, request): adapter = get_adapter() try: user = User.objects.get(email=self.cleaned_data.get('email')) user.artist = self.artist user.save() except ObjectDoesNotExist: user = adapter.new_user(request) user = adapter.save_user(request, user, self) user.artist = self.artist user.save() self.custom_signup(request, user) # TODO: Move into adapter `save_user` ? setup_user_email(request, user, []) send_email_confirmation(request, user, signup=True, activate_view='artist_registration_confirm_email') return user
def save(self): request = self.context.get('request') user = get_user_model()( username=self.get_cleaned_data()['username'], name=self.get_cleaned_data()['name'], email=self.get_cleaned_data()['email'] ) user.set_password(self.get_cleaned_data()['password1']) # check if user is authenticated or has perm for adding user , which is register for staff if request.user.is_authenticated() and request.user.has_perm('user.add_user'): user.is_staff = True user.save() else: user.save() setup_user_email(request, user, []) return user
def save(self, request, connect=False): """ Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts) """ assert not self.is_existing user = self.user user.save() self.account.user = user self.account.save() if app_settings.STORE_TOKENS and self.token: self.token.account = self.account self.token.save() if connect: # TODO: Add any new email addresses automatically? pass else: setup_user_email(request, user, self.email_addresses)
def save(self, request, connect=False): """ Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts) """ assert not self.is_existing user = self.account.user user.save() self.account.user = user self.account.save() if self.token: self.token.account = self.account self.token.expires_at = timezone.now() + timedelta(hours=2) self.token.save() if connect: # TODO: Add any new email addresses automatically? pass else: setup_user_email(request, user, self.email_addresses)
def create(self, request, *args, **kwargs): params = request.data email = params.get('email') password = params.get('password') full_name = params.get('full_name') try: user = User.objects.create_user(email, password, full_name=full_name, active=True, channel='Android') social_data = request.data.get('social') if social_data: try: SocialLoginToken.create(user, social_data) except ValueError as e: raise APIException(str(e)) setup_user_email(request, user, []) send_email_confirmation(request, user, signup=True) except IntegrityError: return Response({'detail': 'The e-mail address already exists.'}, status=400) except Exception as e: return Response({'detail': str(e)}, status=400) return Response(self.serializer_class(user).data, status=status.HTTP_200_OK)
def save(self, request, connect=False): """ Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts) """ assert not self.is_existing user = self.account.user user.save() self.account.user = user self.account.save() if self.token: self.token.account = self.account self.token.save() if connect: # TODO: Add any new email addresses automatically? pass else: # fix for VIDK-36 in YT self.email_addresses = filter(lambda x: x.user_id, self.email_addresses) # endfix setup_user_email(request, user, self.email_addresses)
def create_user_from_invite(self, password=None, accept=True, **kwargs): '''This is a utility function that creates a new user, with an associated profile and organization, from an existing invite. It should be used to programmatically create users, similar to django.contrib.auth.models.UserManager.create_user() If no password is supplied, this will assign an unusable password to the user. This method adapts steps from: allauth.account.forms.SignUpForm.save() allauth.account.forms.SignUpForm.save.adapter.save_user() user_accounts.forms.SignUpForm.custom_signup() allauth.account.utils.setup_user_email() This will mark the invite as accepted, or as designated in the `accept` option. ''' if accept: self.accepted = True self.save() # get the right adapter allauth_adapter = get_adapter() MockRequest = namedtuple('MockRequest', 'session') mock_request = MockRequest(session={}) # get an empty instance of designated U ser model user = allauth_adapter.new_user(request=mock_request) data = dict(email=self.email) if password: data['password1'] = password MockForm = namedtuple('MockForm', 'cleaned_data') user = allauth_adapter.save_user( request=mock_request, user=user, form=MockForm(cleaned_data=data) ) user.groups.add(*self.groups) user_accounts.models.UserProfile.create_from_invited_user( user, self, **kwargs) allauth_account_utils.setup_user_email(mock_request, user, []) return user
def save(self, request, connect=False): """ Saves a new account. Note that while the account is new, the user may be an existing one (when connecting accounts) """ SocialApp = get_social_app_model() SocialAccount = get_social_account_model() assert not self.is_existing app = SocialApp.objects.get_current(provider=self.account.provider, request=request) self.request = request user = self.user user.save() self.account.user = user self.account.app = app self.account.save() if app_settings.STORE_TOKENS and self.token: self.token.account = self.account self.token.save() if connect: # TODO: Add any new email addresses automatically? pass else: setup_user_email(request, user, self.email_addresses)
def invite_members(self, request): adapter = get_adapter() members = [] for email in self.cleaned_data.get('member_emails'): try: user = User.objects.get(email=email) if not user.institution: user.institution = self.institution user.save() members.append(user) except ObjectDoesNotExist: user = adapter.new_user(request) user.email = email user.institution = self.institution user.set_unusable_password() adapter.populate_username(request, user) user.save() setup_user_email(request, user, []) members.append(user) send_email_confirmation_task.delay(user_id=user.id, signup=True) storage = messages.get_messages(request) storage.used = True messages.success(request, 'Members successfully invited') return members
def _process_signup(request, sociallogin): # If email is specified, check for duplicate and if so, no auto signup. auto_signup = app_settings.AUTO_SIGNUP email = user_email(sociallogin.account.user) if auto_signup: # Let's check if auto_signup is really possible... if email: if account_settings.UNIQUE_EMAIL: if email_address_exists(email): # Oops, another user already has this address. We # cannot simply connect this social account to the # existing user. Reason is that the email adress may # not be verified, meaning, the user may be a hacker # that has added your email address to his account in # the hope that you fall in his trap. We cannot check # on 'email_address.verified' either, because # 'email_address' is not guaranteed to be verified. auto_signup = False # FIXME: We redirect to signup form -- user will # see email address conflict only after posting # whereas we detected it here already. elif app_settings.EMAIL_REQUIRED: # Nope, email is required and we don't have it yet... auto_signup = False # Stop here if invitations are required if auth_settings.INVITATION_REQUIRED: # Check for valid invitation key in session if 'invitation_key' not in request.session \ or not InvitationKey.objects.is_key_valid(request.session['invitation_key']): return HttpResponseRedirect(auth_settings.NO_INVITATION_REDIRECT) if not auto_signup: request.session['socialaccount_sociallogin'] = sociallogin url = reverse('socialaccount_signup') ret = HttpResponseRedirect(url) else : # If we're still on auto signup, stop if invitations are required if auth_settings.INVITATION_REQUIRED: # Check for valid invitation key in session if 'invitation_key' not in request.session \ or not InvitationKey.objects.is_key_valid(request.session['invitation_key']): return HttpResponseRedirect(auth_settings.NO_INVITATION_REDIRECT) # Continue with auto signup # FIXME: This part contains a lot of duplication of logic # ("closed" rendering, create user, send email, in active # etc..) try: if not get_account_adapter().is_open_for_signup(request): return render(request, "account/signup_closed.html") except ImmediateHttpResponse as e: return e.response u = sociallogin.account.user if account_settings.USER_MODEL_USERNAME_FIELD: user_username(u, generate_unique_username(user_username(u) or email or 'user')) for field in ['last_name', 'first_name']: if hasattr(u, field): truncated_value = (user_field(u, field) or '') \ [0:User._meta.get_field(field).max_length] user_field(u, field, truncated_value) user_email(u, email or '') u.set_unusable_password() sociallogin.save(request) # Make sure the user has a primary email address if EmailAddress.objects.filter(user=u).count() == 0: setup_user_email(request, u) ret = complete_social_signup(request, sociallogin) return ret