Compare commits
10 Commits
8d6e16da35
...
e411e71b89
Author | SHA1 | Date | |
---|---|---|---|
|
e411e71b89 | ||
|
d7411d90c4 | ||
|
abdb62fd55 | ||
|
7c7f554fd0 | ||
|
5e6baf64c3 | ||
|
4f98c97880 | ||
|
b5c8c005c6 | ||
|
30b629235f | ||
|
505528c595 | ||
|
c71934ca98 |
9
Dockerfile
Normal file
9
Dockerfile
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
FROM greyltc/archlinux-aur:yay
|
||||||
|
WORKDIR /alkator
|
||||||
|
COPY . .
|
||||||
|
run pacman -Syu python python-weasyprint python-dateutil python-django npm --noconfirm
|
||||||
|
RUN sudo -u ab -D~ bash -c 'yay -Syu --removemake --needed --noprogressbar --noconfirm python-daphne'
|
||||||
|
RUN cd frontent && npm install && npm run build && rm -rf node_modules && cd ..
|
||||||
|
RUN python manage.py collectstatic
|
||||||
|
EXPOSE 8002
|
||||||
|
CMD ["/usr/bin/daphne", "alkator.asgi:application", "-p", "8002"]
|
@ -32,6 +32,7 @@ CSRF_TRUSTED_ORIGINS = ['https://alkator.cz', 'https://beta.alkator.cz']
|
|||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
|
'daphne',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
'django.contrib.auth',
|
'django.contrib.auth',
|
||||||
'django.contrib.contenttypes',
|
'django.contrib.contenttypes',
|
||||||
@ -70,6 +71,7 @@ TEMPLATES = [
|
|||||||
]
|
]
|
||||||
|
|
||||||
WSGI_APPLICATION = 'alkator.wsgi.application'
|
WSGI_APPLICATION = 'alkator.wsgi.application'
|
||||||
|
ASGI_APPLICATION = 'alkator.asgi.application'
|
||||||
|
|
||||||
SESSION_COOKIE_SECURE = True
|
SESSION_COOKIE_SECURE = True
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ Including another URLconf
|
|||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
from django.conf.urls.static import static
|
||||||
from alkatorapi.views import (
|
from alkatorapi.views import (
|
||||||
register_user, register_racer,
|
register_user, register_racer,
|
||||||
login, logout,
|
login, logout,
|
||||||
@ -51,4 +52,4 @@ urlpatterns = [
|
|||||||
path('api/cart/select_delivery', select_delivery),
|
path('api/cart/select_delivery', select_delivery),
|
||||||
path('api/cart/delivery', delivery),
|
path('api/cart/delivery', delivery),
|
||||||
path('api/forgotten_password', forgotten_password),
|
path('api/forgotten_password', forgotten_password),
|
||||||
]
|
] + static('/', document_root='frontend/build')
|
||||||
|
@ -10,7 +10,7 @@ class RacerAdmin(admin.ModelAdmin):
|
|||||||
|
|
||||||
@admin.register(Product)
|
@admin.register(Product)
|
||||||
class ProductAdmin(admin.ModelAdmin):
|
class ProductAdmin(admin.ModelAdmin):
|
||||||
list_display = ("name", "description", "price", "quantity")
|
list_display = ("name", "description", "price", "hidden", "quantity")
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Invoice)
|
@admin.register(Invoice)
|
||||||
|
@ -85,24 +85,43 @@ def forgotten_password(request):
|
|||||||
user = DjangoUser.objects.get(username=request.POST['email'])
|
user = DjangoUser.objects.get(username=request.POST['email'])
|
||||||
except DjangoUser.DoesNotExist:
|
except DjangoUser.DoesNotExist:
|
||||||
return HttpResponse('{"reason":"Účet nenalezen!"}', status=404, content_type='application/json')
|
return HttpResponse('{"reason":"Účet nenalezen!"}', status=404, content_type='application/json')
|
||||||
if user.profile.forgotten_password_code != request.POST['code']:
|
if user.profile.forgotten_password_code != request.POST['code'].strip():
|
||||||
return HttpResponse('{"reason":"Špatný kód!"}', status=400, content_type='application/json')
|
return HttpResponse('{"reason":"Špatný kód!"}', status=400, content_type='application/json')
|
||||||
user.set_password(request.POST['password1'])
|
user.set_password(request.POST['password1'])
|
||||||
user.save()
|
user.save()
|
||||||
|
user.profile.forgotten_password_code = None
|
||||||
|
user.profile.save()
|
||||||
auth_login(request, user)
|
auth_login(request, user)
|
||||||
|
return HttpResponse('{"success":"Úspěšně změněné heslo uživatele ' + user.email + '!", "redirect":"/#"}', content_type='application/json')
|
||||||
|
|
||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def login(request):
|
def login(request):
|
||||||
if "forgotten_password" in request.POST:
|
if "forgotten_password" in request.POST:
|
||||||
email = request.POST["email"]
|
email = request.POST["email"]
|
||||||
|
try:
|
||||||
user = DjangoUser.objects.get(username=email)
|
user = DjangoUser.objects.get(username=email)
|
||||||
|
except DjangoUser.DoesNotExist:
|
||||||
|
return HttpResponse('{"reason":"Nezadané jméno nebo uživatel neexistuje!"}', status=404, content_type='application/json')
|
||||||
code = secrets.token_urlsafe(10)
|
code = secrets.token_urlsafe(10)
|
||||||
user.profile.forgotten_password_code = code
|
user.profile.forgotten_password_code = code
|
||||||
user.profile.save()
|
user.profile.save()
|
||||||
mail = EmailMessage("zapomenuté heslo v Alkátor Race", f"""{code} https://alkator.cz/#forgotten_password""", "info@alkator.cz", [request.POST["email"]])
|
mail = EmailMessage("zapomenuté heslo v Alkátor Race", f"""Zdravím tě Alkátore,
|
||||||
mail.send()
|
|
||||||
|
kód pro změnu hesla: {code}
|
||||||
|
|
||||||
|
Změna hesla probíhá na stránce: https://alkator.cz/#forgotten_password
|
||||||
|
|
||||||
|
Na tento email není třeba odpovídat, protože je generován automaticky. V případě potřeby pište na info@alkator.cz .
|
||||||
|
|
||||||
|
ALKÁTOR TEAM
|
||||||
|
email: info@alkator.cz
|
||||||
|
tel: + 420 728 018 088
|
||||||
|
web: https://alkator.cz""", "info@alkator.cz", [email])
|
||||||
|
if mail.send():
|
||||||
return HttpResponse('{"success":"Úspěšně poslán kód pro obnovení hesla uživatele '+ user.email + '", "redirect":"/#forgotten_password"}', content_type='application/json')
|
return HttpResponse('{"success":"Úspěšně poslán kód pro obnovení hesla uživatele '+ user.email + '", "redirect":"/#forgotten_password"}', content_type='application/json')
|
||||||
|
else:
|
||||||
|
return HttpResponse('{"reason":"Nepovedlo se odelat email"}', status=400, content_type='application/json')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
user = authenticate(request, username=request.POST['email'], password=request.POST['password'])
|
user = authenticate(request, username=request.POST['email'], password=request.POST['password'])
|
||||||
@ -117,7 +136,6 @@ def login(request):
|
|||||||
|
|
||||||
@csrf_exempt
|
@csrf_exempt
|
||||||
def logout(request):
|
def logout(request):
|
||||||
|
|
||||||
auth_logout(request)
|
auth_logout(request)
|
||||||
return redirect("/#")
|
return redirect("/#")
|
||||||
|
|
||||||
|
@ -515,7 +515,7 @@ class Main extends Component {
|
|||||||
<label for="password2" class="form-label">Nové heslo znova:</label>
|
<label for="password2" class="form-label">Nové heslo znova:</label>
|
||||||
<input type="password" class="form-control" name="password2"/>
|
<input type="password" class="form-control" name="password2"/>
|
||||||
</div>
|
</div>
|
||||||
<button type="submit" class="btn btn-primary">Přihlásit</button>
|
<button type="submit" class="btn btn-primary">Obnovit heslo a přihlásit</button>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user