Files
bbs/internal/textui/access.go
T
Claude b41f59ec55 Add access levels: levels, flags, requirements, limits, validation
Users have a level (0-255) and flags (A-Z).  [level N] sections say what
a range of levels may do: time online a day (warned at 5 and 1 minutes,
hung up at the end; doors' limits cut to what is left), downloads a day
(counted by every way: the BBS, 3270, FTP, the API), and whether they
may post, mail (else only the sysop), chat, page, download, upload and
open doors.

Requirements ("30 F !X", "sysop") are put on message areas (reading and
posting), file areas (downloading and uploading), doors, menus and menu
items ("x = menu:extras Extras | 50 X").  They are checked in the core,
so the text BBS, 3270s, FTP, NNTP and the API keep them alike: an area a
user may not read is not listed, opened or found by number or
Message-ID.

New users start at new_user_level and are told they wait; the sysop
validates them on the BBS (V on the main menu), by bbs user
waiting/validate/level/flags, or by PATCH /api/v1/admin/users.  Users
see their access in the profile and /api/v1/me; no one changes their
own.  Drop files carry the caller's level.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01AFQhReUqUc7F5srk2hViqr
2026-10-12 08:49:46 +00:00

62 lines
1.5 KiB
Go

package textui
import (
"fmt"
"strconv"
"github.com/Neo-Desktop/bbs-sec/internal/bbs"
)
// validate: the sysop goes through the users waiting to be validated.
func (s *session) validate() error {
t := s.t
waiting, err := s.b.Store.UsersBelow(s.b.ValidatedLevel)
if err != nil {
return err
}
for _, w := range waiting {
t.Println("")
t.Println(t.C(Cyan, w.Name) + t.C(Dim, fmt.Sprintf(" from %q, since %s, %d calls, level %d",
w.Location, w.Created.Format("2006-01-02"), w.Logins, w.Level)))
t.Print(fmt.Sprintf("[V]alidate (level %d), [L]evel..., [K] lock, [S]kip, [Q]uit: ", s.b.ValidatedLevel))
k, err := t.Key()
if err != nil {
return err
}
t.Println(string(k))
by := fmt.Sprintf("node %d: %s", s.n.Num, s.user.Name)
switch k {
case 'V':
if err := s.b.Validate(w, by); err != nil {
return err
}
t.Println(t.C(Green, "Validated."))
case 'L':
n, err := t.Input("Level (0-255): ", 3)
if err != nil {
return err
}
l, err := strconv.Atoi(n)
if err != nil || l < 0 || l > bbs.MaxLevel {
t.Println(t.C(Red, "That is not a level."))
continue
}
if err := s.b.Store.SetLevel(w.ID, l); err != nil {
return err
}
s.b.Log.Printf("%s set %s's level to %d", by, w.Name, l)
t.Println(t.C(Green, "Done."))
case 'K':
if err := s.b.Store.SetLocked(w.ID, true); err != nil {
return err
}
s.b.Log.Printf("%s locked %s", by, w.Name)
t.Println(t.C(Green, "Locked."))
case 'Q', '\r':
return nil
}
}
t.Println("No one else is waiting.")
return nil
}