177 lines
8.9 KiB
PHP
177 lines
8.9 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once __DIR__ . '/okr_bootstrap.php';
|
|
okr_ensure_schema();
|
|
|
|
if (!empty($_SESSION['okr_user'])) {
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
|
|
$errors = [];
|
|
|
|
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
try {
|
|
okr_verify_csrf();
|
|
|
|
$organizationName = trim((string) ($_POST['organization_name'] ?? ''));
|
|
$organizationSlug = strtolower(trim((string) ($_POST['organization_slug'] ?? '')));
|
|
$fullName = trim((string) ($_POST['full_name'] ?? ''));
|
|
$email = strtolower(trim((string) ($_POST['email'] ?? '')));
|
|
$role = trim((string) ($_POST['role'] ?? 'Staff'));
|
|
|
|
if ($organizationName === '' || strlen($organizationName) < 2) {
|
|
$errors[] = 'Enter a valid organization name.';
|
|
}
|
|
|
|
if ($organizationSlug === '' || !preg_match('/^[a-z0-9-]{3,40}$/', $organizationSlug)) {
|
|
$errors[] = 'Use a lowercase org key with letters, numbers, or dashes.';
|
|
}
|
|
|
|
if ($fullName === '' || strlen($fullName) < 2) {
|
|
$errors[] = 'Enter your full name.';
|
|
}
|
|
|
|
if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
|
|
$errors[] = 'Enter a valid work email address.';
|
|
}
|
|
|
|
if (!in_array($role, okr_roles(), true)) {
|
|
$errors[] = 'Choose a valid role.';
|
|
}
|
|
|
|
if ($errors === []) {
|
|
$_SESSION['okr_user'] = [
|
|
'organization_name' => $organizationName,
|
|
'organization_slug' => $organizationSlug,
|
|
'name' => $fullName,
|
|
'email' => $email,
|
|
'role' => $role,
|
|
];
|
|
|
|
okr_flash('success', 'Welcome back. Your workspace is ready.');
|
|
header('Location: index.php');
|
|
exit;
|
|
}
|
|
} catch (Throwable $exception) {
|
|
$errors[] = $exception->getMessage();
|
|
}
|
|
}
|
|
|
|
$projectName = okr_app_name();
|
|
$projectDescription = okr_meta_description();
|
|
$projectImageUrl = env_value('PROJECT_IMAGE_URL');
|
|
$csrfToken = okr_csrf_token();
|
|
?>
|
|
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title><?= e($projectName) ?> · Secure sign in</title>
|
|
<meta name="description" content="<?= e($projectDescription) ?>">
|
|
<?php if ($projectDescription !== ''): ?>
|
|
<meta property="og:description" content="<?= e($projectDescription) ?>">
|
|
<meta property="twitter:description" content="<?= e($projectDescription) ?>">
|
|
<?php endif; ?>
|
|
<?php if ($projectImageUrl !== ''): ?>
|
|
<meta property="og:image" content="<?= e($projectImageUrl) ?>">
|
|
<meta property="twitter:image" content="<?= e($projectImageUrl) ?>">
|
|
<?php endif; ?>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH" crossorigin="anonymous">
|
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?= time() ?>">
|
|
</head>
|
|
<body class="auth-shell">
|
|
<div class="container-fluid px-0">
|
|
<div class="row g-0 min-vh-100">
|
|
<div class="col-lg-6 auth-panel d-flex flex-column justify-content-between p-4 p-lg-5">
|
|
<div>
|
|
<div class="d-flex align-items-center justify-content-between mb-5">
|
|
<a class="brand-mark" href="login.php">Aligned OKR</a>
|
|
<span class="eyebrow-tag">Multi-tenant SaaS</span>
|
|
</div>
|
|
<div class="hero-copy">
|
|
<p class="text-uppercase tiny-label mb-3">Strategic execution platform</p>
|
|
<h1 class="display-title mb-3">Run one tenant-aware OKR workflow from sign-in to approval.</h1>
|
|
<p class="text-secondary mb-4">This initial release gives each organization an isolated workspace with a clean dashboard, scoped OKR records, manager approvals, and lightweight analytics.</p>
|
|
</div>
|
|
<div class="row g-3 mt-2">
|
|
<div class="col-sm-6">
|
|
<div class="surface-card h-100 p-3">
|
|
<div class="small text-secondary mb-2">Included now</div>
|
|
<div class="fw-semibold mb-1">My OKRs workflow</div>
|
|
<p class="small text-secondary mb-0">Create objectives, track key results, and route them into approval with automatic score calculation.</p>
|
|
</div>
|
|
</div>
|
|
<div class="col-sm-6">
|
|
<div class="surface-card h-100 p-3">
|
|
<div class="small text-secondary mb-2">Ready for managers</div>
|
|
<div class="fw-semibold mb-1">Approval inbox</div>
|
|
<p class="small text-secondary mb-0">Managers, directors, CEOs, and super admins can review progress, leave feedback, and approve or reject.</p>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="small text-secondary mt-4">Version 0.1 · Designed for secure internal planning and execution.</div>
|
|
</div>
|
|
<div class="col-lg-6 d-flex align-items-center justify-content-center p-4 p-lg-5 auth-form-column">
|
|
<div class="surface-card auth-card w-100">
|
|
<div class="mb-4">
|
|
<p class="text-uppercase tiny-label mb-2">Secure workspace access</p>
|
|
<h2 class="h3 mb-2">Sign in to your organization</h2>
|
|
<p class="text-secondary mb-0">Use a work email and role to enter an isolated tenant workspace.</p>
|
|
</div>
|
|
|
|
<?php if ($errors !== []): ?>
|
|
<div class="alert alert-danger border-0 small" role="alert">
|
|
<strong>Please fix the following:</strong>
|
|
<ul class="mb-0 mt-2 ps-3">
|
|
<?php foreach ($errors as $error): ?>
|
|
<li><?= e($error) ?></li>
|
|
<?php endforeach; ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="post" class="row g-3">
|
|
<input type="hidden" name="csrf_token" value="<?= e($csrfToken) ?>">
|
|
<div class="col-12">
|
|
<label class="form-label" for="organization_name">Organization name</label>
|
|
<input class="form-control" id="organization_name" name="organization_name" type="text" placeholder="Northstar Holdings" value="<?= e($_POST['organization_name'] ?? '') ?>" required>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="organization_slug">Organization key</label>
|
|
<input class="form-control" id="organization_slug" name="organization_slug" type="text" placeholder="northstar-holdings" value="<?= e($_POST['organization_slug'] ?? '') ?>" required>
|
|
<div class="form-text">Used to isolate all OKR records for this organization.</div>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label" for="full_name">Full name</label>
|
|
<input class="form-control" id="full_name" name="full_name" type="text" placeholder="Morgan Lee" value="<?= e($_POST['full_name'] ?? '') ?>" required>
|
|
</div>
|
|
<div class="col-md-6">
|
|
<label class="form-label" for="email">Work email</label>
|
|
<input class="form-control" id="email" name="email" type="email" placeholder="morgan@northstar.com" value="<?= e($_POST['email'] ?? '') ?>" required>
|
|
</div>
|
|
<div class="col-12">
|
|
<label class="form-label" for="role">Role</label>
|
|
<select class="form-select" id="role" name="role" required>
|
|
<?php foreach (okr_roles() as $roleOption): ?>
|
|
<option value="<?= e($roleOption) ?>" <?= ($roleOption === ($_POST['role'] ?? 'Manager')) ? 'selected' : '' ?>><?= e($roleOption) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<div class="col-12 d-grid gap-2 mt-2">
|
|
<button class="btn btn-brand" type="submit">Enter workspace</button>
|
|
<div class="small text-secondary">Roles included: Admin, CEO, Director, Manager, Team, Staff, plus Super Admin for SaaS oversight.</div>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz" crossorigin="anonymous"></script>
|
|
<script src="assets/js/main.js?v=<?= time() ?>" defer></script>
|
|
</body>
|
|
</html>
|