mirror of
https://github.com/ajurna/cbwebreader.git
synced 2025-12-06 06:17:17 +00:00
Merge pull request #7 from apoclyps/docker-support
[ISSUE-3] Adding docker support
This commit is contained in:
@@ -6,26 +6,19 @@ from snowpenguin.django.recaptcha2.widgets import ReCaptchaWidget
|
||||
|
||||
class LoginForm(forms.Form):
|
||||
|
||||
username = forms.CharField(max_length=50,
|
||||
label='',
|
||||
widget=forms.TextInput(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
'placeholder': 'Username',
|
||||
'autofocus': True,
|
||||
'required': True,
|
||||
}
|
||||
))
|
||||
password = forms.CharField(label='Password',
|
||||
widget=forms.PasswordInput(
|
||||
attrs={
|
||||
'class': 'form-control',
|
||||
'placeholder': 'Username',
|
||||
'required': True,
|
||||
}
|
||||
))
|
||||
username = forms.CharField(
|
||||
max_length=50,
|
||||
label="",
|
||||
widget=forms.TextInput(
|
||||
attrs={"class": "form-control", "placeholder": "Username", "autofocus": True, "required": True}
|
||||
),
|
||||
)
|
||||
password = forms.CharField(
|
||||
label="Password",
|
||||
widget=forms.PasswordInput(attrs={"class": "form-control", "placeholder": "Username", "required": True}),
|
||||
)
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(LoginForm, self).__init__(*args, **kwargs)
|
||||
if settings.CBREADER_USE_RECAPTCHA if hasattr(settings, 'CBREADER_USE_RECAPTCHA') else False:
|
||||
self.fields['captcha'] = ReCaptchaField(widget=ReCaptchaWidget())
|
||||
if settings.CBREADER_USE_RECAPTCHA if hasattr(settings, "CBREADER_USE_RECAPTCHA") else False:
|
||||
self.fields["captcha"] = ReCaptchaField(widget=ReCaptchaWidget())
|
||||
|
||||
@@ -9,45 +9,28 @@ def comic_login(request):
|
||||
if request.POST:
|
||||
form = LoginForm(request.POST)
|
||||
if form.is_valid():
|
||||
user = authenticate(username=form.cleaned_data['username'],
|
||||
password=form.cleaned_data['password'])
|
||||
user = authenticate(username=form.cleaned_data["username"], password=form.cleaned_data["password"])
|
||||
if user is not None:
|
||||
if user.is_active:
|
||||
login(request, user)
|
||||
if 'next' in request.GET:
|
||||
return redirect(request.GET['next'])
|
||||
if "next" in request.GET:
|
||||
return redirect(request.GET["next"])
|
||||
else:
|
||||
return redirect('/comic/')
|
||||
return redirect("/comic/")
|
||||
else:
|
||||
return render(request,
|
||||
'comic_auth/login.html',
|
||||
{
|
||||
'error': True,
|
||||
})
|
||||
return render(request, "comic_auth/login.html", {"error": True})
|
||||
else:
|
||||
return render(request,
|
||||
'comic_auth/login.html',
|
||||
{
|
||||
'error': True,
|
||||
'form': form
|
||||
})
|
||||
return render(request, "comic_auth/login.html", {"error": True, "form": form})
|
||||
else:
|
||||
return render(request,
|
||||
'comic_auth/login.html',
|
||||
{
|
||||
'error': True,
|
||||
'form': form
|
||||
})
|
||||
return render(request, "comic_auth/login.html", {"error": True, "form": form})
|
||||
else:
|
||||
if not User.objects.all().exists():
|
||||
return redirect('/setup/')
|
||||
return redirect("/setup/")
|
||||
form = LoginForm()
|
||||
context = {
|
||||
'form': form
|
||||
}
|
||||
return render(request, 'comic_auth/login.html', context)
|
||||
context = {"form": form}
|
||||
return render(request, "comic_auth/login.html", context)
|
||||
|
||||
|
||||
def comic_logout(request):
|
||||
logout(request)
|
||||
return redirect('/login/')
|
||||
return redirect("/login/")
|
||||
|
||||
Reference in New Issue
Block a user