aboutsummaryrefslogtreecommitdiff
path: root/internal/admin
diff options
context:
space:
mode:
Diffstat (limited to 'internal/admin')
-rw-r--r--internal/admin/server.go14
-rw-r--r--internal/admin/static/map.js21
2 files changed, 22 insertions, 13 deletions
diff --git a/internal/admin/server.go b/internal/admin/server.go
index 9c62249..96b5981 100644
--- a/internal/admin/server.go
+++ b/internal/admin/server.go
@@ -754,12 +754,8 @@ func (s *AdminServer) handleLogin(w http.ResponseWriter, r *http.Request) {
}
// Expensive password hashing stays off the owner. Reload the account
- // inside the task so an upgrade cannot overwrite a concurrent character
- // rename/create or a password/admin change made since authentication.
- var upgradedHash string
- if player.NeedsRehash(acc.PasswordHash) {
- upgradedHash, _ = player.HashPassword(password)
- }
+ // inside the task so a concurrent character rename/create or a
+ // password/admin change made since authentication is not overwritten.
authorized := false
if !s.runOnOwner(func() {
current, err := s.accountStore.LoadAccount(account)
@@ -767,12 +763,6 @@ func (s *AdminServer) handleLogin(w http.ResponseWriter, r *http.Request) {
return
}
authorized = true
- if upgradedHash != "" {
- current.PasswordHash = upgradedHash
- if err := s.accountStore.SaveAccount(current); err != nil {
- log.Printf("admin login: password rehash save for %s: %v", account, err)
- }
- }
}) {
writeJSONError(w, "game is shutting down", http.StatusServiceUnavailable)
return
diff --git a/internal/admin/static/map.js b/internal/admin/static/map.js
index f8cee51..4c0cae4 100644
--- a/internal/admin/static/map.js
+++ b/internal/admin/static/map.js
@@ -2056,7 +2056,26 @@ async function doSavePanel() {
var el = $('#roomName'); if (el) r.name = el.value;
el = $('#roomColor'); if (el) r.color = el.value;
- el = $('#roomDesc'); if (el && el.value) r.description = [{text: el.value}];
+ // Only rewrite description when the textarea actually changed. The
+ // textarea is populated by joining every variant, so unconditionally
+ // assigning a single variant here destroyed conditional descriptions on
+ // any unrelated panel save (rename, block_transport toggle, ...).
+ el = $('#roomDesc');
+ if (el) {
+ var origDesc = '';
+ if (Array.isArray(r.description)) {
+ origDesc = r.description.map(function(d) { return d.text || ''; }).join('\n\n');
+ } else if (typeof r.description === 'string') {
+ origDesc = r.description;
+ }
+ if (el.value !== origDesc) {
+ var hasConditional = Array.isArray(r.description) && r.description.some(function(d) { return d.condition; });
+ if (hasConditional && !confirm('This room has conditional descriptions. Saving the edited text will replace them all with one description. Continue?')) {
+ return;
+ }
+ r.description = el.value ? [{text: el.value}] : [];
+ }
+ }
el = $('#roomBlockTransport'); if (el) r.block_transport = el.checked;
if (currentRoomData && currentRoomData.room) {