Browse Source

Don't convert user ID to/from numbers

master
Christian Fischer 9 months ago
parent
commit
43b7248537
2 changed files with 5 additions and 9 deletions
  1. +3
    -3
      server/groups.rkt
  2. +2
    -6
      server/rest.rkt

+ 3
- 3
server/groups.rkt View File

@@ -35,7 +35,7 @@
(define (add-user dbc id name)
(redis-hash-set! dbc
"users"
(number->string id)
id
(jsexpr->bytes (hash 'user_name name))))

; A group is a product of two sets of users, admins and members. A
@@ -59,13 +59,13 @@
(deserialize-group id
(redis-hash-ref dbc
"groups"
(number->string id))))
id)))

;; NB: like add-user, for testing in the REPL
(define (add-group dbc id admins members)
(redis-hash-set! dbc
"groups"
(number->string id)
id
(jsexpr->bytes
(hash 'admins (set->list admins)
'members (set->list members)))))


+ 2
- 6
server/rest.rkt View File

@@ -36,9 +36,7 @@
(let* ((res (get-resource res-id))
(mask (get-mask-for-user
res
(~> user-id
(bytes->string/utf-8)
(string->number)))))
(bytes->string/utf-8 user-id))))
(~> (apply-mask (dict-ref resource-types
(resource-type res))
mask)
@@ -79,9 +77,7 @@
(string->symbol)))
(action (bytes->string/utf-8 action)))
(let ((action (access-action res
(~> user-id
(bytes->string/utf-8)
(string->number))
(bytes->string/utf-8 user-id)
(cons branch action))))
(if action
(run-action action


Loading…
Cancel
Save