feat: admin + first user functionality

This commit is contained in:
Ben Allfree
2025-12-08 10:38:44 -08:00
parent a8a5727bd1
commit f30f83e607
3 changed files with 55 additions and 1 deletions

45
CHANGELOG.md Normal file
View File

@@ -0,0 +1,45 @@
# Changelog
All notable changes to LoBBS will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- Logo assets with logo.pxd and logo.webp files
- Walkthrough video link in README
- Admin user functionality - first registered user automatically becomes administrator
### Changed
- Updated README with improved documentation, license information, and links
## [1.1.0] - 2025-12-05
### Added
- MPM plugin compatibility
### Fixed
- Direct messages now properly filter out broadcasts
## [1.0.1] - 2025-12-05
### Changed
- Enhanced installation documentation with Mesh Forge method
- Updated installation instructions for MPM integration
## [1.0.0] - 2025-11-28
### Added
- Initial release of LoBBS (LoDB Bulletin Board System)
- User registration and authentication
- Bulletin board messaging system
- Direct messaging between users
- Session management
- User directory and search functionality
[Unreleased]: https://github.com/MeshEnvy/lobbs/compare/v1.1.0...HEAD
[1.1.0]: https://github.com/MeshEnvy/lobbs/compare/v1.0.1...v1.1.0
[1.0.1]: https://github.com/MeshEnvy/lobbs/compare/v1.0.0...v1.0.1
[1.0.0]: https://github.com/MeshEnvy/lobbs/compare/c911244...v1.0.0

View File

@@ -138,19 +138,23 @@ bool LoBBSDal::createUser(const char *username, const char *password, uint32_t n
// Calculate UUID first (username with host node ID as salt)
lodb_uuid_t userUuid = usernameToUuid(username, hostNodeId);
// Check if this is the first user (no existing users)
bool isFirstUser = (db->count("users") == 0);
// Create user record
meshtastic_LoBBSUser user = meshtastic_LoBBSUser_init_zero;
strncpy(user.username, username, sizeof(user.username) - 1);
user.uuid = userUuid;
user.password_hash.size = 32;
hashPassword(password, user.password_hash.bytes);
user.is_admin = isFirstUser;
LoDbError err = db->insert("users", userUuid, &user);
if (err != LODB_OK) {
LOG_ERROR("Failed to create user: %s", username);
return false;
}
LOG_INFO("Created user: %s", username);
LOG_INFO("Created user: %s (admin: %s)", username, isFirstUser ? "yes" : "no");
// Log in the user (create session)
return loginUser(username, nodeId);

View File

@@ -22,6 +22,11 @@ message LoBBSUser {
* User UUID - deterministic hash derived from username
*/
uint64 uuid = 3;
/*
* Whether this user is an administrator
*/
bool is_admin = 4;
}
/*