Add account registration with signup policy acceptance
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / Coding Standards (pull_request) Successful in 52s
CI / PHPStan (pull_request) Successful in 1m1s
CI / Tests (PHP 8.2) (pull_request) Successful in 48s
CI / Tests (PHP 8.3) (pull_request) Successful in 45s
CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / No Debug Code (pull_request) Successful in 2s
CI / Build Plugin Zip (pull_request) Has been skipped
CI / Coding Standards (pull_request) Successful in 52s
CI / PHPStan (pull_request) Successful in 1m1s
CI / Tests (PHP 8.2) (pull_request) Successful in 48s
CI / Tests (PHP 8.3) (pull_request) Successful in 45s
Implements #16: invite-only student self-registration through a front-end page, accepting signup-scoped policies at account creation. Policy domain: - us_policies.acceptance_scope (signup/booking/both); Policy::appliesTo(); PolicyRepository::findForScope(); scope threaded through PolicyService, the REST create, the admin controller, and the Policies form. - PolicyAcceptance::REG_ACCOUNT (registration_id = the new user's ID). Auth: - Invite value object + InviteRepository; us_invites table. - RegistrationController + Invites admin page (manage_students): invite an email, share the registration link, revoke. - RegistrationPage ([us_student_register] shortcode): validates the invite token, collects name/password, renders signup-scoped published policies with required acceptance, creates the us_student user, records account-type acceptances, marks the invite accepted, and logs the user in. - RoleManager: manage_students cap added to STUDIO_ADMIN_CAPS. Invite-only is implemented; the us_registration_mode self_approval path is a documented future seam. Docs: docs/features/account-registration.md; policies.md updated. Tests: tests/Unit/Auth/ (Invite, InviteRepository) plus Policy scope updates. composer test (104), cs, and PHPStan level 6 all pass. Refs #16 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
if (! defined('ABSPATH')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/** @var list<\Unsupervised\Schedular\Auth\Invite> $pendingInvites */
|
||||
?>
|
||||
<div class="wrap">
|
||||
<h1><?php esc_html_e('Invites', 'unsupervised-schedular'); ?></h1>
|
||||
<p class="description"><?php esc_html_e('Invite a student by email, then send them the registration link below. They complete signup and accept any required policies through the [us_student_register] page.', 'unsupervised-schedular'); ?></p>
|
||||
|
||||
<h2><?php esc_html_e('Invite a Student', 'unsupervised-schedular'); ?></h2>
|
||||
<form method="post">
|
||||
<?php wp_nonce_field('usc_invite_action'); ?>
|
||||
<input type="hidden" name="usc_action" value="invite">
|
||||
<table class="form-table">
|
||||
<tr>
|
||||
<th><label for="email"><?php esc_html_e('Email', 'unsupervised-schedular'); ?></label></th>
|
||||
<td><input type="email" name="email" id="email" class="regular-text" required></td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php submit_button(esc_html__('Send Invite', 'unsupervised-schedular')); ?>
|
||||
</form>
|
||||
|
||||
<h2><?php esc_html_e('Pending Invites', 'unsupervised-schedular'); ?></h2>
|
||||
|
||||
<?php if (empty($pendingInvites)) : ?>
|
||||
<p><?php esc_html_e('No pending invites.', 'unsupervised-schedular'); ?></p>
|
||||
<?php else : ?>
|
||||
<table class="wp-list-table widefat fixed striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><?php esc_html_e('Email', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Registration link', 'unsupervised-schedular'); ?></th>
|
||||
<th><?php esc_html_e('Actions', 'unsupervised-schedular'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($pendingInvites as $invite) : ?>
|
||||
<?php $link = esc_url(add_query_arg('us_invite', $invite->token, home_url('/'))); ?>
|
||||
<tr>
|
||||
<td><?php echo esc_html($invite->email); ?></td>
|
||||
<td>
|
||||
<input type="text" class="large-text code" readonly value="<?php echo esc_attr($link); ?>" onclick="this.select()">
|
||||
<span class="description"><?php esc_html_e('Point this token (?us_invite=…) at the page containing the registration shortcode.', 'unsupervised-schedular'); ?></span>
|
||||
</td>
|
||||
<td>
|
||||
<form method="post" style="display:inline;">
|
||||
<?php wp_nonce_field('usc_invite_action'); ?>
|
||||
<input type="hidden" name="usc_action" value="revoke">
|
||||
<input type="hidden" name="invite_id" value="<?php echo esc_attr((string) $invite->id); ?>">
|
||||
<button type="submit" class="button button-small button-link-delete">
|
||||
<?php esc_html_e('Revoke', 'unsupervised-schedular'); ?>
|
||||
</button>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user