|
|
@ -19,10 +19,11 @@ import ( |
|
|
// Handler holds the funcs and attributes for the
|
|
|
// Handler holds the funcs and attributes for the
|
|
|
// http communication
|
|
|
// http communication
|
|
|
type Handler struct { |
|
|
type Handler struct { |
|
|
config config.Handlers |
|
|
config config.Handlers |
|
|
store store.Store |
|
|
store store.Store |
|
|
engine *gin.Engine |
|
|
engine *gin.Engine |
|
|
oAuthConf *oauth2.Config |
|
|
oAuthConf *oauth2.Config |
|
|
|
|
|
DoNotCheckConfigViaGet bool // DoNotCheckConfigViaGet is for the unit testing usage
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// New initializes the http handlers
|
|
|
// New initializes the http handlers
|
|
|
@ -56,15 +57,17 @@ func (h *Handler) setTemplateFromFS(name string) error { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (h *Handler) checkIfSecretExist() error { |
|
|
func (h *Handler) checkIfSecretExist() error { |
|
|
conf := config.Get() |
|
|
if h.DoNotCheckConfigViaGet { |
|
|
if conf.Handlers.Secret == nil { |
|
|
conf := config.Get() |
|
|
b := make([]byte, 128) |
|
|
if conf.Handlers.Secret == nil { |
|
|
if _, err := rand.Read(b); err != nil { |
|
|
b := make([]byte, 128) |
|
|
return err |
|
|
if _, err := rand.Read(b); err != nil { |
|
|
} |
|
|
return err |
|
|
conf.Handlers.Secret = b |
|
|
} |
|
|
if err := config.Set(conf); err != nil { |
|
|
conf.Handlers.Secret = b |
|
|
return err |
|
|
if err := config.Set(conf); err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
return nil |
|
|
return nil |
|
|
|