use client for user create action
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
2022-01-20 23:31:09 +01:00
parent 88d9a76785
commit d583db5450
3 changed files with 27 additions and 30 deletions

View File

@@ -37,7 +37,7 @@ func NewHTTPServer(cfg *gpaste.ServerConfig) *HTTPServer {
// Create initial user
// TODO: Do properly
user := &users.User{Username: "admin"}
user := &users.User{Username: "admin", Role: users.RoleAdmin}
user.SetPassword("admin")
srv.Users.Store(user)

View File

@@ -71,7 +71,7 @@ func (s *HTTPServer) MiddlewareAuthentication(next http.Handler) http.Handler {
ctx = context.WithValue(ctx, authCtxAuthLevel, claims.Role)
ctx = context.WithValue(ctx, authCtxClaims, claims)
withCtx := r.WithContext(ctx)
s.Logger.Debugw("Request is authenticated.", "req_id", reqID, "username", claims.Subject)
s.Logger.Debugw("Request is authenticated.", "req_id", reqID, "username", claims.Subject, "role", claims.Role)
next.ServeHTTP(w, withCtx)
}