1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-19 05:09:42 +02:00

Closes #96 -- user re-auth on permissions change

This commit is contained in:
Harvey Kandola 2017-04-27 12:49:10 +01:00
parent be02ad2726
commit 831dfce3cb
2 changed files with 31 additions and 2 deletions

View file

@ -211,12 +211,25 @@ func Authorize(w http.ResponseWriter, r *http.Request, next http.HandlerFunc) {
context.Administrator = user.Admin
context.Editor = user.Editor
context.Global = user.Global
var state struct {
Active bool `json:"active"`
Admin bool `json:"admin"`
Editor bool `json:"editor"`
}
state.Active = user.Active
state.Admin = user.Admin
state.Editor = user.Editor
sb, err := json.Marshal(state)
w.Header().Add("X-Documize-Status", string(sb))
}
request.SetContext(r, context)
p = request.GetPersister(r)
// Middleware moves on if we say 'yes' -- autheticated or allow anon access.
// Middleware moves on if we say 'yes' -- authenticated or allow anon access.
authenticated = context.Authenticated || org.AllowAnonymousAccess
}