def login(request): '''Log a user in. ''' extra_context = {} if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): nickname = form.data['nickname'].strip().lower() f = friendfeed.FriendFeed(nickname, form.data['key']) data = f.validate() if 'errorCode' in data: return error(request, data) request.session['nickname'] = nickname request.session['key'] = form.data['key'] return HttpResponseRedirect('/?message=settings') else: form = LoginForm() extra_context['form'] = form return render_to_response('login.html', extra_context, context_instance = RequestContext(request))
def login(request): """Log a user in. """ extra_context = {} if request.method == "POST": form = LoginForm(request.POST) if form.is_valid(): nickname = form.data["nickname"].strip().lower() f = friendfeed.FriendFeed(nickname, form.data["key"]) data = f.validate() if "errorCode" in data: return error(request, data) request.session["nickname"] = nickname request.session["key"] = form.data["key"] return HttpResponseRedirect("/?message=settings") else: form = LoginForm() extra_context["form"] = form return render_to_response("login.html", extra_context, context_instance=RequestContext(request))
def login(request): '''Log a user in. ''' from fftogo.forms import LoginForm extra_context = {} if request.method == 'POST': form = LoginForm(request.POST) if form.is_valid(): try: nickname = form.data['nickname'].strip().lower() f = friendfeed.FriendFeed(nickname, form.data['key']) data = f.fetch_home_feed(num=1) request.session['nickname'] = nickname request.session['key'] = form.data['key'] return HttpResponseRedirect('/?message=settings') except Exception, e: if e[0] == 401: del request.session['nickname'] del request.session['key'] return HttpResponseRedirect(reverse(str(e)))