Exemple #1
0
def login(request):
    if request.user.is_authenticated():
        return feeds(request)
    else:
        if request.method == 'POST':
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    django_login(request, user)
                    if 'next' in request.GET:
                        return redirect(request.GET['next'])
                    else:
                        return redirect('/')
                else:
                    messages.add_message(request, messages.ERROR,
                                         'Your account is desactivated.')
                    return render(request, 'core/cover.html')
            else:
                messages.add_message(request, messages.ERROR,
                                     'Username or password invalid.')
                return render(request, 'core/cover.html')
        else:
            return render(request, 'core/cover.html')
Exemple #2
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if not form.is_valid():
            return render(request, 'auth/signup.html', {'form': form})
        else:
            username = form.cleaned_data.get('username')
            email = form.cleaned_data.get('email')
            password = form.cleaned_data.get('password')
            User.objects.create_user(username=username, password=password, email=email)
            user = authenticate(username=username, password=password)
            django_login(request, user)
            return feeds(request)
    else:
        return render(request, 'auth/signup.html', {'form': SignUpForm()})
Exemple #3
0
def signup(request):
    if request.method == 'POST':
        form = SignUpForm(request.POST)
        if not form.is_valid():
            return render(request, 'auth/signup.html', {'form': form})
        else:
            username = form.cleaned_data.get('username')
            email = form.cleaned_data.get('email')
            password = form.cleaned_data.get('password')
            User.objects.create_user(username=username,
                                     password=password,
                                     email=email)
            user = authenticate(username=username, password=password)
            django_login(request, user)
            return feeds(request)
    else:
        return render(request, 'auth/signup.html', {'form': SignUpForm()})
Exemple #4
0
def login(request):
    if request.user.is_authenticated():
        return feeds(request)
    else:
        if request.method == 'POST':
            username = request.POST['username']
            password = request.POST['password']
            user = authenticate(username=username, password=password)
            if user is not None:
                if user.is_active:
                    django_login(request, user)
                    if 'next' in request.GET:
                        return redirect(request.GET['next'])
                    else:
                        return redirect('/')
                else:
                    messages.add_message(request, messages.ERROR, 'Your account is desactivated.')
                    return render(request, 'core/cover.html')
            else:
                messages.add_message(request, messages.ERROR, 'Username or password invalid.')
                return render(request, 'core/cover.html')
        else:
            return render(request, 'core/cover.html')
Exemple #5
0
def home(request):
    if request.user.is_authenticated():
        return feeds(request)
    else:
        return render(request, 'core/cover.html')
Exemple #6
0
def home(request):
    if request.user.is_authenticated:
        return feeds(request)
    else:
        return render(request, 'core/cover.html')
Exemple #7
0
def home(request):
    return feeds(request)
Exemple #8
0
def home(request):
    if request.user.is_authenticated():
        return feeds(request)
    else:
        return render(request, 'core/entrada.html')
Exemple #9
0
def home(request):
    return feeds(request)
Exemple #10
0
def home(request):
    if request.user.is_authenticated():
        # 注意这个写法,没有用redirect便捷函数
        return feeds(request)
    else:
        return render(request, 'core/cover.html')
Exemple #11
0
def home(request):
    if request.user.is_authenticated():
        set_user_default_tribe_tag(request.user.id, request.session)
        return feeds(request)
    else:
        return render(request, "core/cover.html")