Example #1
0
    def login(self, request):
        user = self.cleaned_data["user"]
        django_login(request, user)

        extra = {"ip_address": get_client_ip(request)}
        log_account_event(user, AccountHistoryLog.ACTIONS.LOGIN, extra)
        return user
Example #2
0
    def login(self, request):
        user = self.cleaned_data["user"]
        user.backend = "django.contrib.auth.backends.ModelBackend"
        django_login(request, user)

        extra = {"ip_address": get_client_ip(request)}
        log_account_event(user, AccountHistoryLog.ACTIONS.S_LOGIN, extra)
        return user
Example #3
0
    def save(self):
        user = self.cleaned_data["user"]
        new_email = self.cleaned_data["new_email"]

        send_verify_email(user, new_email)

        extra = {"new_email": new_email}
        log_account_event(user, AccountHistoryLog.ACTIONS.CHANGE_EMAIL_REQUEST,
                          extra)
Example #4
0
    def save(self):
        password = self.cleaned_data["password1"]
        user = self.cleaned_data["user"]
        token_obj = self.cleaned_data["token_obj"]
        user.set_password(password)

        user.save()
        token_obj.delete()
        log_account_event(user, AccountHistoryLog.ACTIONS.FORGOT_PASSWORD_SUCCESS)
Example #5
0
    def save(self):
        email = self.cleaned_data["email"]
        try:
            user = User.objects.get(email__iexact=email, verified=True)
        except User.DoesNotExist:
            return

        send_forgot_password(user)
        log_account_event(user, AccountHistoryLog.ACTIONS.FORGOT_PASSWORD_REQUEST, {"email": email})
Example #6
0
    def save(self):
        data = self.cleaned_data
        user = User.objects.create_user(
            username=data["username"], password=data["password1"], email=data["email"]
        )
        send_verify_email(user, data["email"])
        send_greeting_email(user, data["email"])

        log_account_event(user, AccountHistoryLog.ACTIONS.SIGNUP)
        return user
Example #7
0
    def save(self):
        user = self.cleaned_data["user"]
        new_email = self.cleaned_data["new_email"]

        user.email = new_email
        user.verified = True
        user.save()

        extra = {"new_email": new_email}
        log_account_event(user, AccountHistoryLog.ACTIONS.CHANGE_EMAIL_SUCCESS,
                          extra)
Example #8
0
    def save(self):
        data = self.cleaned_data["info"]
        username = data["email"].split("@")[0]
        while User.objects.filter(username=username).exists():
            username += str(random.randint(10))

        user = User.objects.create_user(
            username=username,
            email=data["email"],
            password=None,
            first_name=data.get("given_name"),
            last_name=data.get("family_name"),
            verified=True,
            social_provider=SOCIAL_PROVIDERS.GOOGLE,
            social_uid=data["sub"],
        )
        send_greeting_email(user, data["email"])
        log_account_event(user, AccountHistoryLog.ACTIONS.S_SIGNUP)
        return user