mirror of
https://github.com/volatiletech/authboss.git
synced 2025-01-24 05:17:10 +02:00
de1c2ed081
- Change changelog format to use keepachangelog standard - Refactor the config to be made of substructs to help organize all the pieces - Add the new interfaces to the configuration - Clean up module loading (no unnecessary reflection to create new value) - Change User interface to have a Get/SetPID not E-mail/Username, this way we don't ever have to refer to one or the other, we just always assume pid. In the case of Confirm/Recover we'll have to make a GetEmail or there won't be a way for us to get the e-mail to send to. - Delete the xsrf nonsense in the core
46 lines
1014 B
Go
46 lines
1014 B
Go
package authboss
|
|
|
|
var registeredModules = make(map[string]Moduler)
|
|
|
|
// Moduler should be implemented by all the authboss modules.
|
|
type Moduler interface {
|
|
// Init the module
|
|
Init(*Authboss) error
|
|
}
|
|
|
|
// RegisterModule with the core providing all the necessary information to
|
|
// integrate into authboss.
|
|
func RegisterModule(name string, m Moduler) {
|
|
registeredModules[name] = m
|
|
}
|
|
|
|
// RegisteredModules returns a list of modules that are currently registered.
|
|
func RegisteredModules() []string {
|
|
mods := make([]string, len(registeredModules))
|
|
i := 0
|
|
for k := range registeredModules {
|
|
mods[i] = k
|
|
i++
|
|
}
|
|
|
|
return mods
|
|
}
|
|
|
|
// LoadedModules returns a list of modules that are currently loaded.
|
|
func (a *Authboss) LoadedModules() []string {
|
|
mods := make([]string, len(a.loadedModules))
|
|
i := 0
|
|
for k := range a.loadedModules {
|
|
mods[i] = k
|
|
i++
|
|
}
|
|
|
|
return mods
|
|
}
|
|
|
|
// IsLoaded checks if a specific module is loaded.
|
|
func (a *Authboss) IsLoaded(mod string) bool {
|
|
_, ok := a.loadedModules[mod]
|
|
return ok
|
|
}
|