ARC_Starter/frontend/create_user.php

24 lines
830 B
PHP

<?php
require 'db.php';
require 'vendor/autoload.php';
$ga = new PHPGangsta_GoogleAuthenticator();
$secret = $ga->createSecret();
$qrCodeUrl = $ga->getQRCodeGoogleUrl('SuperArc', $secret);
$username = 'anders';
$fullname = 'Anders Ostensvik';
$email = 'anders@ostsik.no';
$phone = '1234567890';
$password = password_hash('yourpassword', PASSWORD_BCRYPT);
$user_role = 'Admin'; // must be one of Admin, Operator, Installer, Client
$access_group = 'default';
$stmt = $pdo->prepare("INSERT INTO users (username, full_name, email, phone, password_hash, totp_secret, user_role, access_group) VALUES (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->execute([$username, $fullname, $email, $phone, $password, $secret, $user_role, $access_group]);
echo "User created. Scan this QR in Google Authenticator: <br>";
echo "<img src='$qrCodeUrl'>";
?>