Think i havent explained my problem very well ...

Since its a Saas the users are inside schemas/tenants one user can have
accounts inside different schemas (they share username and password) ... i
want to let the user move throught different tenants more or less freely
... now i have designed a view where the user can select the other tenants
he is also in.
Using that view I can correctly switch him to his other user object in the
other schemas when i have the cookie setting as ".domain.ext" like
explained on the djanco documentation.

But we really want to be able to have different versions of the app on
different browser apps, so that approach doesnt work for us. When i change
the cookie configuration to "domain.ext" doesnt work because the original
view is on one tenant and the next view (where the just logged user really
belongs) is inside other tenant then the old cookie is deleted.

So the question is how can i programmatically set the cookie correctly on
the new view so the user that really belongs to that tenat is still
authenticated.

2016-02-01 12:37 GMT+00:00 'Tom Evans' via Django users <
django-users@googlegroups.com>:

> On Mon, Feb 1, 2016 at 10:13 AM, monoBOT <monobot.s...@gmail.com> wrote:
> > Hello django!
> >
> > Im creating a saas with django, due to some project requirements need to
> > manually change the user "on the fly" but have problems with the cookie,
> > since I dont know how to manually (read programatically) set it.
> >
> > Any insights or a good place to start? Thanks!
> >
>
> I would simply add a secondary custom auth backend that always
> authenticates the user if the argument switch_login is true:
>
> class SwitchAuthBackend(object):
>     def authenticate(self, switch_login=False, new_user=None):
>         if switch_login:
>             return new_user
>     def get_user(self, user_id):
>         try:
>             return User.objects.get(pk=user_id)
>         except User.DoesNotExist:
>             pass
>
> Now you can switch user simply using authenticate() and login():
>
> new_user = ...
> authenticated_user = authenticate(switch_login=True, new_user=new_user)
> login(request, authenticated_user)
>
> This would be an alternative to poking around and manually
> manipulating the session attributes.
>
> Cheers
>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAFHbX1JjAzjA7rgpNLR4iQvFzqyD7M9GtYSXzYtauK4eacjhnw%40mail.gmail.com
> .
> For more options, visit https://groups.google.com/d/optout.
>



-- 
*monoBOT*
Visite mi sitio(Visit my site): monobotsoft.es/blog/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2BxOsGAnjXnetvX23YpezOUuUUfL4eQGztku4P%2ByeYnt%3D6-%2B-w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to