Ящики из веб-почты: администратор создаёт no-reply@, monitor@, support@, задаёт новый пароль, выключает
continuous-integration/drone/pr Build is passing
continuous-integration/drone/pr Build is passing
Регистрация остаётся закрытой. Администраторы — MAIL_ADMINS (по умолчанию первый ящик); роль не в базе, укравший ящик себя админом не сделает. API /api/admin/mailboxes, сгенерированный пароль — один раз в ответе, в лог не пишется. Настройки → MAILBOXES (видно только администратору). Тесты: MailboxAdminControllerTest (5), всего 73. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { Injectable, inject } from '@angular/core';
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { Observable } from 'rxjs';
|
||||
import { Attachment, BlacklistEntry, Contact, Draft, Folder, Message, Profile, ServerConfig } from './models';
|
||||
import { Attachment, BlacklistEntry, Contact, Draft, Folder, Mailbox, MailboxCreated, Message, Profile, ServerConfig } from './models';
|
||||
|
||||
/** The mail server REST API (same origin, /api). */
|
||||
@Injectable({ providedIn: 'root' })
|
||||
@@ -17,6 +17,18 @@ export class ApiService {
|
||||
return this.http.put('/api/me/password', { currentPassword, newPassword });
|
||||
}
|
||||
|
||||
// mailboxes — administrators only
|
||||
mailboxes(): Observable<Mailbox[]> { return this.http.get<Mailbox[]>('/api/admin/mailboxes'); }
|
||||
createMailbox(email: string, displayName: string, password: string): Observable<MailboxCreated> {
|
||||
return this.http.post<MailboxCreated>('/api/admin/mailboxes', { email, displayName, password });
|
||||
}
|
||||
newMailboxPassword(id: number): Observable<MailboxCreated> {
|
||||
return this.http.post<MailboxCreated>(`/api/admin/mailboxes/${id}/password`, {});
|
||||
}
|
||||
setMailboxActive(id: number, active: boolean): Observable<Mailbox> {
|
||||
return this.http.put<Mailbox>(`/api/admin/mailboxes/${id}/active`, { active });
|
||||
}
|
||||
|
||||
// folders
|
||||
folders(): Observable<Folder[]> { return this.http.get<Folder[]>('/api/folders'); }
|
||||
createFolder(name: string): Observable<Folder> { return this.http.post<Folder>('/api/folders', { name }); }
|
||||
|
||||
@@ -53,6 +53,25 @@ export interface Profile {
|
||||
usedBytes: number;
|
||||
quotaBytes: number;
|
||||
createdAt: string;
|
||||
admin?: boolean; // may manage mailboxes (Settings → Mailboxes)
|
||||
}
|
||||
|
||||
/** MailboxAdminController.MailboxView */
|
||||
export interface Mailbox {
|
||||
id: number;
|
||||
email: string;
|
||||
displayName: string;
|
||||
active: boolean;
|
||||
admin: boolean;
|
||||
usedBytes: number;
|
||||
quotaBytes: number;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
/** password — generated by the server, shown once; null when the administrator chose it */
|
||||
export interface MailboxCreated {
|
||||
mailbox: Mailbox;
|
||||
password: string | null;
|
||||
}
|
||||
|
||||
export interface ServerConfig {
|
||||
|
||||
Reference in New Issue
Block a user