66 lines
1.6 KiB
Bash
66 lines
1.6 KiB
Bash
#!/bin/bash
|
||
# Restore sonrası kullanıcı oluşturma scripti
|
||
|
||
cd /Users/beyhan/Projeler/Python/dj52
|
||
|
||
echo "==================================="
|
||
echo "RESTORE SONRASI KULLANICI OLUŞTURMA"
|
||
echo "==================================="
|
||
|
||
# Mevcut kullanıcıları kontrol et
|
||
python manage.py shell -c "
|
||
from accounts.models import CustomUser
|
||
users = CustomUser.objects.all()
|
||
print(f'\nToplam {users.count()} kullanıcı var')
|
||
for user in users:
|
||
print(f' - {user.email} (Staff: {user.is_staff}, Superuser: {user.is_superuser})')
|
||
"
|
||
|
||
echo ""
|
||
echo "Yeni superuser oluşturmak ister misiniz? (y/n)"
|
||
read -r answer
|
||
|
||
if [ "$answer" = "y" ]; then
|
||
echo "Email:"
|
||
read -r email
|
||
echo "Şifre:"
|
||
read -rs password
|
||
|
||
python manage.py shell -c "
|
||
from accounts.models import CustomUser
|
||
try:
|
||
user = CustomUser.objects.create_superuser(email='$email', password='$password')
|
||
print(f'\n✓ Superuser oluşturuldu: {user.email}')
|
||
except Exception as e:
|
||
print(f'\n✗ Hata: {e}')
|
||
"
|
||
fi
|
||
|
||
echo ""
|
||
echo "Mevcut bir kullanıcının şifresini değiştirmek ister misiniz? (y/n)"
|
||
read -r answer2
|
||
|
||
if [ "$answer2" = "y" ]; then
|
||
echo "Kullanıcı email:"
|
||
read -r user_email
|
||
echo "Yeni şifre:"
|
||
read -rs new_password
|
||
|
||
python manage.py shell -c "
|
||
from accounts.models import CustomUser
|
||
try:
|
||
user = CustomUser.objects.get(email='$user_email')
|
||
user.set_password('$new_password')
|
||
user.save()
|
||
print(f'\n✓ Şifre değiştirildi: {user.email}')
|
||
except CustomUser.DoesNotExist:
|
||
print('\n✗ Kullanıcı bulunamadı')
|
||
except Exception as e:
|
||
print(f'\n✗ Hata: {e}')
|
||
"
|
||
fi
|
||
|
||
echo ""
|
||
echo "İşlem tamamlandı!"
|
||
|