Mercurial > gemma
view auth/encode.go @ 270:d1b0d964af09
Dont restrict listing/updating of users to sys_admins.
Each user should be able to list/change her/his own informations.
Added a new middleware checker "all" for this.
This stricly not needed because all users are at least
a waterway_user. This is for the case theat we may later
(unlikely) add other roles and for explicitness of model constraints.
author | Sascha L. Teichmann <sascha.teichmann@intevation.de> |
---|---|
date | Mon, 30 Jul 2018 12:31:46 +0200 |
parents | f345edb409b2 |
children |
line wrap: on
line source
package auth import ( "encoding/binary" "io" ) type binReader struct { r io.Reader err error } func (r *binReader) read(x interface{}) { if r.err == nil { r.err = binary.Read(r.r, binary.BigEndian, x) } } func (r *binReader) readString(s *string) { if r.err != nil { return } var l uint32 if r.err = binary.Read(r.r, binary.BigEndian, &l); r.err != nil { return } b := make([]byte, l) if r.err = binary.Read(r.r, binary.BigEndian, b); r.err != nil { return } *s = string(b) } type binWriter struct { w io.Writer err error } func (w *binWriter) write(x interface{}) { if w.err == nil { w.err = binary.Write(w.w, binary.BigEndian, x) } } func (w *binWriter) writeString(s string) { if w.err == nil { w.err = binary.Write(w.w, binary.BigEndian, uint32(len(s))) } if w.err == nil { w.err = binary.Write(w.w, binary.BigEndian, []byte(s)) } }