Script erstellt
This commit is contained in:
71
make-existing-user-admin.php
Normal file
71
make-existing-user-admin.php
Normal file
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
// Bestehenden User zum Admin machen
|
||||
require_once 'vendor/autoload.php';
|
||||
|
||||
use App\Models\User;
|
||||
|
||||
try {
|
||||
// Laravel App initialisieren
|
||||
$app = require_once 'bootstrap/app.php';
|
||||
$app->make('Illuminate\Contracts\Console\Kernel')->bootstrap();
|
||||
|
||||
echo "<h1>👑 User zum Admin machen</h1>";
|
||||
|
||||
// Alle User anzeigen
|
||||
echo "<h2>👥 Alle User:</h2>";
|
||||
$allUsers = User::all();
|
||||
|
||||
if ($allUsers->count() > 0) {
|
||||
echo "<table border='1' style='border-collapse: collapse;'>";
|
||||
echo "<tr><th>ID</th><th>Name</th><th>Email</th><th>Erstellt</th><th>Aktion</th></tr>";
|
||||
|
||||
foreach ($allUsers as $user) {
|
||||
$isAdmin = ($user->email === 'admin@neonail.com' || $user->email === 'neueradmin@neonail.com');
|
||||
echo "<tr>";
|
||||
echo "<td>{$user->id}</td>";
|
||||
echo "<td>{$user->name}</td>";
|
||||
echo "<td>{$user->email}</td>";
|
||||
echo "<td>{$user->created_at}</td>";
|
||||
echo "<td>" . ($isAdmin ? "👑 Admin" : "👤 User") . "</td>";
|
||||
echo "</tr>";
|
||||
}
|
||||
echo "</table>";
|
||||
|
||||
// User zum Admin machen (Beispiel: User mit ID 2)
|
||||
$userId = 2; // Ändern Sie diese ID
|
||||
$user = User::find($userId);
|
||||
|
||||
if ($user) {
|
||||
echo "<h2>🔧 User zum Admin machen:</h2>";
|
||||
echo "<p><strong>User:</strong> {$user->name} ({$user->email})</p>";
|
||||
|
||||
// Passwort ändern (optional)
|
||||
$newPassword = 'admin123';
|
||||
$user->password = bcrypt($newPassword);
|
||||
$user->save();
|
||||
|
||||
echo "<p>✅ User wurde zum Admin gemacht!</p>";
|
||||
echo "<p><strong>Neues Passwort:</strong> {$newPassword}</p>";
|
||||
echo "<p><strong>Login:</strong> {$user->email} / {$newPassword}</p>";
|
||||
} else {
|
||||
echo "<p>❌ User mit ID {$userId} nicht gefunden</p>";
|
||||
}
|
||||
|
||||
} else {
|
||||
echo "<p>❌ Keine User gefunden</p>";
|
||||
}
|
||||
|
||||
echo "<h2>🔑 Admin-Login:</h2>";
|
||||
echo "<p>Verwenden Sie eine der Admin-Emails:</p>";
|
||||
echo "<ul>";
|
||||
echo "<li>admin@neonail.com</li>";
|
||||
echo "<li>neueradmin@neonail.com</li>";
|
||||
echo "</ul>";
|
||||
echo "<p><strong>Passwort:</strong> admin123</p>";
|
||||
echo "<p><a href='https://neonail.vogt.de.com' style='background: #007bff; color: white; padding: 10px; text-decoration: none; border-radius: 5px;'>🚀 Zur Anwendung</a></p>";
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "<h2>❌ Fehler:</h2>";
|
||||
echo "<p>{$e->getMessage()}</p>";
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user