Esempio n. 1
0
def login_and_forward(request,  user,  newquestion = False,  newanswer = False):
    old_session = request.session.session_key
    user.backend = "django.contrib.auth.backends.ModelBackend"
    logging.debug('attached auth.backends.ModelBackend to this FB user')
    login(request,  user)
    logging.debug('user logged in!')
    
    from forum.models import user_logged_in
    user_logged_in.send(user=user,session_key=old_session,sender=None)
    logging.debug('user_logged_in signal sent')
    
    if (newquestion):
        from forum.models import Question
        question = Question.objects.filter(author=user).order_by('-added_at')[0]
        logging.debug('redirecting to newly posted question')
        return HttpResponseRedirect(question.get_absolute_url())
        
    if (newanswer):
        from forum.models import Answer
        answer = Answer.objects.filter(author=user).order_by('-added_at')[0]
        logging.debug('redirecting to newly posted answer')
        return HttpResponseRedirect(answer.get_absolute_url())
        
    logging.debug('redirecting to front page')
    return HttpResponseRedirect('/')
Esempio n. 2
0
def login_and_forward(request,  user, forward=None, message=None):
    old_session = request.session.session_key
    user.backend = "django.contrib.auth.backends.ModelBackend"
    login(request,  user)

    from forum.models import user_logged_in
    user_logged_in.send(user=user,session_key=old_session,sender=None)

    if not forward:
        signin_action = request.session.get('on_signin_action', None)
        if not signin_action:
            forward = request.session.get('on_signin_url', None)

            if not forward:
                forward = reverse('index')
        else:
            try:
                forward = POST_SIGNIN_ACTIONS[signin_action](user)
            except:
                forward = reverse('index')

    if message is None:
        message = _("Welcome back %s, you are now logged in") % user.username

    request.user.message_set.create(message=message)
    return HttpResponseRedirect(forward)
Esempio n. 3
0
File: views.py Progetto: Mig29x/X-29
def login(request,user):
    from django.contrib.auth import login as _login
    from forum.models import user_logged_in #custom signal
    #1) get old session key
    session_key = request.session.session_key
    #2) login and get new session key
    _login(request,user)
    #3) send signal with old session key as argument
    user_logged_in.send(user=user,session_key=session_key,sender=None)
Esempio n. 4
0
File: views.py Progetto: yyms/CNPROG
def login(request, user):
    from django.contrib.auth import login as _login
    from forum.models import user_logged_in  #custom signal
    #1) get old session key
    session_key = request.session.session_key
    #2) login and get new session key
    _login(request, user)
    #3) send signal with old session key as argument
    user_logged_in.send(user=user, session_key=session_key, sender=None)
Esempio n. 5
0
def login(request,user):
    from django.contrib.auth import login as _login
    from forum.models import user_logged_in #custom signal

    if settings.USE_EXTERNAL_LEGACY_LOGIN == True:
        EXTERNAL_LOGIN_APP.api.login(request,user)

    #1) get old session key
    session_key = request.session.session_key
    #2) login and get new session key
    _login(request,user)
    #3) send signal with old session key as argument
    user_logged_in.send(user=user,session_key=session_key,sender=None)
Esempio n. 6
0
def login(request,user):
    from django.contrib.auth import login as _login
    from forum.models import user_logged_in #custom signal

    if settings.USE_EXTERNAL_LEGACY_LOGIN == True:
        EXTERNAL_LOGIN_APP.api.login(request,user)

    #1) get old session key
    session_key = request.session.session_key
    #2) login and get new session key
    _login(request,user)
    #3) send signal with old session key as argument
    logging.debug('logged in user %s with session key %s' % (user.username, session_key))
    user_logged_in.send(user=user,session_key=session_key,sender=None)
Esempio n. 7
0
def login_and_forward(request,  user,  newquestion = False,  newanswer = False):
    old_session = request.session.session_key
    user.backend = "django.contrib.auth.backends.ModelBackend"
    login(request,  user)
    
    from forum.models import user_logged_in
    user_logged_in.send(user=user,session_key=old_session,sender=None)
    
    if (newquestion):
        from forum.models import Question
        question = Question.objects.filter(author=user).order_by('-added_at')[0]
        return HttpResponseRedirect(question.get_absolute_url())
        
    if (newanswer):
        from forum.models import Answer
        answer = Answer.objects.filter(author=user).order_by('-added_at')[0]
        return HttpResponseRedirect(answer.get_absolute_url())
        
    return HttpResponseRedirect('/')
Esempio n. 8
0
def login_and_forward(request, user, newquestion=False, newanswer=False):
    old_session = request.session.session_key
    user.backend = "django.contrib.auth.backends.ModelBackend"
    login(request, user)

    from forum.models import user_logged_in
    user_logged_in.send(user=user, session_key=old_session, sender=None)

    if (newquestion):
        from forum.models import Question
        question = Question.objects.filter(
            author=user).order_by('-added_at')[0]
        return HttpResponseRedirect(question.get_absolute_url())

    if (newanswer):
        from forum.models import Answer
        answer = Answer.objects.filter(author=user).order_by('-added_at')[0]
        return HttpResponseRedirect(answer.get_absolute_url())

    return HttpResponseRedirect('/')
Esempio n. 9
0
def login(request,user):
    from django.contrib.auth import login as _login
    from forum.models import user_logged_in #custom signal

    if settings.USE_EXTERNAL_LEGACY_LOGIN == True:
        EXTERNAL_LOGIN_APP.api.login(request,user)

    #1) get old session key
    session_key = request.session.session_key
    #2) get old search state
    search_state = None
    if 'search_state' in request.session:
        search_state = request.session['search_state']

    #3) login and get new session key
    _login(request,user)
    #4) transfer search_state to new session if found
    if search_state:
        search_state.set_logged_in()
        request.session['search_state'] = search_state
    #5) send signal with old session key as argument
    logging.debug('logged in user %s with session key %s' % (user.username, session_key))
    user_logged_in.send(user=user,session_key=session_key,sender=None)