Implement Issue #1: User Accounts & Profiles
- Admin-only account creation (no self-registration); invite-token flow
replaces the public /auth/register endpoint
- New volunteer fields: phone, is_trainee, operational_roles,
notification_preference, admin_notes, last_login, completed_shifts
- Role-scoped profile editing: volunteers update name/phone only;
admins update all fields including notes and trainee flag
- /auth/activate endpoint for invite-token-based account activation
- /api/v1/volunteers/{id}/invite for admin to resend invite links
- last_login recorded on each successful authentication
Tests:
- Go: handler tests (auth rules, create, activate, update scoping) via
Storer/AuthServicer interfaces and fake store; auth unit tests for
HashPassword, IssueToken, and Parse
- Frontend: RTL tests for Activate, Profile, and Volunteers pages
- Fixed CRA 5 + React Router v7 Jest compatibility (moduleNameMapper +
TextEncoder polyfill)
- Replaced stale CRA App.test.tsx placeholder with real tests
CI:
- .gitea/workflows/ci.yml runs go vet, go test, tsc, and npm test on
every push and pull request
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -25,14 +25,18 @@ export const api = {
|
||||
// Auth
|
||||
login: (email: string, password: string) =>
|
||||
request<{ token: string }>('POST', '/auth/login', { email, password }),
|
||||
register: (name: string, email: string, password: string, role = 'volunteer') =>
|
||||
request<Volunteer>('POST', '/auth/register', { name, email, password, role }),
|
||||
activate: (token: string, password: string) =>
|
||||
request<Volunteer>('POST', '/auth/activate', { token, password }),
|
||||
|
||||
// Volunteers
|
||||
listVolunteers: () => request<Volunteer[]>('GET', '/volunteers'),
|
||||
getVolunteer: (id: number) => request<Volunteer>('GET', `/volunteers/${id}`),
|
||||
updateVolunteer: (id: number, data: Partial<Volunteer>) =>
|
||||
createVolunteer: (data: CreateVolunteerInput) =>
|
||||
request<AdminVolunteer>('POST', '/volunteers', data),
|
||||
listVolunteers: () => request<Volunteer[] | AdminVolunteer[]>('GET', '/volunteers'),
|
||||
getVolunteer: (id: number) => request<Volunteer | AdminVolunteer>('GET', `/volunteers/${id}`),
|
||||
updateVolunteer: (id: number, data: Partial<UpdateVolunteerInput>) =>
|
||||
request<Volunteer>('PUT', `/volunteers/${id}`, data),
|
||||
resendInvite: (id: number) =>
|
||||
request<{ invite_token: string }>('POST', `/volunteers/${id}/invite`, {}),
|
||||
|
||||
// Schedules
|
||||
listSchedules: () => request<Schedule[]>('GET', '/schedules'),
|
||||
@@ -64,10 +68,42 @@ export interface Volunteer {
|
||||
email: string;
|
||||
role: 'admin' | 'volunteer';
|
||||
active: boolean;
|
||||
is_trainee: boolean;
|
||||
phone?: string;
|
||||
operational_roles: string;
|
||||
notification_preference: string;
|
||||
last_login?: string;
|
||||
completed_shifts: number;
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
export interface AdminVolunteer extends Volunteer {
|
||||
admin_notes?: string;
|
||||
invite_token?: string;
|
||||
}
|
||||
|
||||
export interface CreateVolunteerInput {
|
||||
name: string;
|
||||
email: string;
|
||||
role?: 'admin' | 'volunteer';
|
||||
is_trainee?: boolean;
|
||||
phone?: string;
|
||||
operational_roles?: string;
|
||||
}
|
||||
|
||||
export interface UpdateVolunteerInput {
|
||||
name?: string;
|
||||
email?: string;
|
||||
phone?: string;
|
||||
role?: 'admin' | 'volunteer';
|
||||
active?: boolean;
|
||||
is_trainee?: boolean;
|
||||
operational_roles?: string;
|
||||
notification_preference?: string;
|
||||
admin_notes?: string;
|
||||
}
|
||||
|
||||
export interface Schedule {
|
||||
id: number;
|
||||
volunteer_id: number;
|
||||
@@ -122,3 +158,11 @@ export interface Notification {
|
||||
read: boolean;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export const OPERATIONAL_ROLES = [
|
||||
'Behaviour Team',
|
||||
'Dog Log Monitor',
|
||||
'Dog Shelter Volunteer',
|
||||
'Trainee',
|
||||
'Floater',
|
||||
] as const;
|
||||
|
||||
Reference in New Issue
Block a user