add auto-signup login and localized auth UI
- backend: userLogin auto-registers missing users and returns auto_registered - frontend: add responsive auth page (login + signup flow via userLogin) with light/dark mode and logo - i18n: wire language switching, add translations for cs/en/es/de - ui/tooling: add Font Awesome integration
This commit is contained in:
@ -4,12 +4,12 @@ require __DIR__ . '/../vendor/autoload.php';
|
||||
|
||||
ob_start();
|
||||
|
||||
$backend_api = new TPsoft\BugreportBackend\API('typescript', 'import.meta.env.VITE_BACKENDAPI_URL', 'backend');
|
||||
$backend_api = new TPsoft\Nutrio\API('typescript', 'import.meta.env.VITE_BACKENDAPI_URL', 'BackendAPI');
|
||||
|
||||
$output = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
$ts_path = realpath(__DIR__ . '/../../frontend/src').'/backend.js';
|
||||
$ts_path = realpath(__DIR__ . '/../../frontend/src').'/BackendAPI.js';
|
||||
$suc = file_put_contents($ts_path, $output);
|
||||
if ($suc === false) {
|
||||
echo "✗ TypeScript store into file failed\n";
|
||||
|
||||
@ -72,8 +72,21 @@ class API extends APIlite {
|
||||
{
|
||||
$email = $this->normalizeEmail($email);
|
||||
$password = $this->normalizePassword($password);
|
||||
$autoRegistered = false;
|
||||
if (!$this->users()->verifyUser($email, $password)) {
|
||||
throw new \Exception('Invalid email or password');
|
||||
$existing = $this->users()->userBy('email', $email);
|
||||
if (is_array($existing)) {
|
||||
throw new \Exception('Invalid email or password');
|
||||
}
|
||||
$userId = $this->users()->user(null, array(
|
||||
'email' => $email,
|
||||
'password_hash' => $this->users()->hashString($password),
|
||||
'created_at' => '`NOW`'
|
||||
));
|
||||
if ($userId === false) {
|
||||
throw new \Exception('Failed to auto-register user');
|
||||
}
|
||||
$autoRegistered = true;
|
||||
}
|
||||
$user = $this->users()->userBy('email', $email);
|
||||
if (!is_array($user) || !isset($user['user_id'])) {
|
||||
@ -87,6 +100,7 @@ class API extends APIlite {
|
||||
}
|
||||
return array(
|
||||
'logged_in' => true,
|
||||
'auto_registered' => $autoRegistered,
|
||||
'user' => $this->mapAuthUser($user)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user