Beispiel #1
0
def welcome(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/dashboard/')

    form = EmailAuthenticationForm()
    return render_to_response('welcome.html',
                              RequestContext(request, {'form': form}))
Beispiel #2
0
def signin(request):
  if request.method == 'POST':
    email = request.POST['email']
    password = request.POST['password']
    user = authenticate(email=email, password=password)

    if (user is not None) and (user.is_active):
      login(request, user)
      facebook_account = FacebookAccount.get_account(request_id=request.user.id)
      twitter_account = TwitterAccount.get_account(request_id=request.user.id)
      if facebook_account is None and twitter_account is None:
        return redirect('/feed/', {'username': email})
      else:
        return redirect('/feed/', {'username': email})
    else:
      form = EmailAuthenticationForm()
      form.non_field_errors = 'Your email and password were incorrect.'
      return render(request, 'index.html', {'form': form})
  else:
    form = EmailAuthenticationForm()

  return render(request, 'index.html', {'form': form})
Beispiel #3
0
def welcome(request):
    if request.user.is_authenticated():
        return HttpResponseRedirect('/dashboard/')

    form = EmailAuthenticationForm()
    return render_to_response(
        'welcome.html',
        RequestContext(
            request, {
                'form': form,
                'error': get_param(request, 'error'),
                'message': get_param(request, 'message'),
                'time': get_param(request, 'time')
            }))
Beispiel #4
0
def signin(request):
    if request.method == 'POST':
        email = request.POST['email']
        password = request.POST['password']
        user = authenticate(email=email, password=password)

        if (user is not None) and (user.is_active):
            login(request, user)
            facebook_account = FacebookAccount.get_account(
                request_id=request.user.id)
            twitter_account = TwitterAccount.get_account(
                request_id=request.user.id)
            if facebook_account is None and twitter_account is None:
                return redirect('/feed/', {'username': email})
            else:
                return redirect('/feed/', {'username': email})
        else:
            form = EmailAuthenticationForm()
            form.non_field_errors = 'Your email and password were incorrect.'
            return render(request, 'index.html', {'form': form})
    else:
        form = EmailAuthenticationForm()

    return render(request, 'index.html', {'form': form})
Beispiel #5
0
 def test_login(self):
     form = EmailAuthenticationForm(
         data={'email': self.email, 'password': self.password}
     )
     self.assertTrue(form.is_valid())