bfjberger / transcendence

ft_transcendence 42
2 stars 2 forks source link

Create player for admin #9

Closed phlearning closed 3 months ago

phlearning commented 4 months ago

When creating the admin through the command, there is no instance of player linked to the user admin. This causes multi issues in the frontend and backend.

Killian-Morin commented 4 months ago

J'ai trouvé et fait une solution qui résout le problème quand on essaie de se connecter via le site "normalement" via le bouton de login: try & except quand la LoginView essaie de récupèrer l'instance du player. À revoir aux niveaux des questions de sécurités edit: !!! quand on se log avec admin/admin dans le front "normal", pas celui de django, on reçoit un token donc on est loggé (sera changé par le .env ?)

phlearning commented 3 months ago

Should be fixed with the commit 585a974 on main: A player is created through the script now:

python manage.py shell <<EOF from django.contrib.auth.models import User from players_manager.models import Player admin_user = User.objects.get(username='admin') if not Player.objects.filter(owner=admin_user).exists(): Player.objects.create(owner=admin_user, nickname=admin_user.username) EOF