mirror of
https://github.com/volatiletech/authboss.git
synced 2025-09-16 09:06:20 +02:00
Fix several lint errors
This commit is contained in:
@@ -49,7 +49,9 @@ func TestAuthGet(t *testing.T) {
|
||||
|
||||
r := mocks.Request("POST")
|
||||
r.URL.RawQuery = "redir=/redirectpage"
|
||||
a.LoginGet(nil, r)
|
||||
if err := a.LoginGet(nil, r); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if responder.Page != PageLogin {
|
||||
t.Error("wanted login page, got:", responder.Page)
|
||||
|
@@ -49,7 +49,7 @@ func TestStateResponseWriterDoubleWritePanic(t *testing.T) {
|
||||
}
|
||||
}()
|
||||
|
||||
w.putClientState()
|
||||
_ = w.putClientState()
|
||||
}
|
||||
|
||||
func TestStateResponseWriterLastSecondWriteHeader(t *testing.T) {
|
||||
|
@@ -267,7 +267,9 @@ func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler {
|
||||
Failure: "Your account has not been confirmed, please check your e-mail.",
|
||||
RedirectPath: ab.Config.Paths.ConfirmNotOK,
|
||||
}
|
||||
ab.Config.Core.Redirector.Redirect(w, r, ro)
|
||||
if err := ab.Config.Core.Redirector.Redirect(w, r, ro); err != nil {
|
||||
logger.Errorf("error redirecting in confirm.Middleware: #%v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -61,7 +61,7 @@ func TestResponder(t *testing.T) {
|
||||
t.Error("code was wrong:", w.Code)
|
||||
}
|
||||
|
||||
if got := w.HeaderMap.Get("Content-Type"); got != "application/json" {
|
||||
if got := w.Result().Header.Get("Content-Type"); got != "application/json" {
|
||||
t.Error("content type was wrong:", got)
|
||||
}
|
||||
|
||||
|
10
lock/lock.go
10
lock/lock.go
@@ -6,8 +6,6 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"github.com/volatiletech/authboss"
|
||||
)
|
||||
|
||||
@@ -18,10 +16,6 @@ const (
|
||||
StoreLocked = "locked"
|
||||
)
|
||||
|
||||
var (
|
||||
errUserMissing = errors.New("user not loaded in BeforeAuth callback")
|
||||
)
|
||||
|
||||
func init() {
|
||||
authboss.RegisterModule("lock", &Lock{})
|
||||
}
|
||||
@@ -175,7 +169,9 @@ func Middleware(ab *authboss.Authboss) func(http.Handler) http.Handler {
|
||||
Failure: "Your account has been locked, please contact the administrator.",
|
||||
RedirectPath: ab.Config.Paths.LockNotOK,
|
||||
}
|
||||
ab.Config.Core.Redirector.Redirect(w, r, ro)
|
||||
if err := ab.Config.Core.Redirector.Redirect(w, r, ro); err != nil {
|
||||
logger.Errorf("error redirecting in lock.Middleware: #%v", err)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@@ -80,7 +80,7 @@ func (a *Authboss) loadModule(name string) error {
|
||||
value.Elem().Set(modVal)
|
||||
}
|
||||
|
||||
mod, ok := value.Interface().(Moduler)
|
||||
mod := value.Interface().(Moduler)
|
||||
a.loadedModules[name] = mod
|
||||
return mod.Init(a)
|
||||
}
|
||||
|
@@ -18,12 +18,7 @@ func init() {
|
||||
RegisterModule(testModName, testMod)
|
||||
}
|
||||
|
||||
type testModule struct {
|
||||
}
|
||||
|
||||
func testHandler(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("testhandler", "test")
|
||||
}
|
||||
type testModule struct{}
|
||||
|
||||
func (t *testModule) Init(a *Authboss) error { return nil }
|
||||
|
||||
|
@@ -86,8 +86,6 @@ type testHarness struct {
|
||||
oauth *OAuth2
|
||||
ab *authboss.Authboss
|
||||
|
||||
bodyReader *mocks.BodyReader
|
||||
responder *mocks.Responder
|
||||
redirector *mocks.Redirector
|
||||
session *mocks.ClientStateRW
|
||||
storer *mocks.ServerStorer
|
||||
|
@@ -137,7 +137,7 @@ func (o *OTP) LoginPost(w http.ResponseWriter, r *http.Request) error {
|
||||
}
|
||||
}
|
||||
|
||||
handled := false
|
||||
var handled bool
|
||||
if matchPassword < 0 {
|
||||
handled, err = o.Authboss.Events.FireAfter(authboss.EventAuthFail, w, r)
|
||||
if err != nil {
|
||||
|
@@ -55,7 +55,6 @@ const (
|
||||
)
|
||||
|
||||
var (
|
||||
errNoSMSEnabled = errors.New("user does not have sms 2fa enabled")
|
||||
errSMSRateLimit = errors.New("user sms send rate-limited")
|
||||
errBadPhoneNumber = errors.New("bad phone number provided")
|
||||
)
|
||||
@@ -177,7 +176,7 @@ func (s *SMS) SendCodeToUser(w http.ResponseWriter, r *http.Request, pid, number
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
suppress = time.Now().UTC().Unix()-last < 10
|
||||
suppress = time.Now().UTC().Unix()-last < smsRateLimitSeconds
|
||||
}
|
||||
|
||||
if suppress {
|
||||
|
@@ -48,13 +48,11 @@ type Recovery struct {
|
||||
|
||||
// Setup the module to provide recovery regeneration routes
|
||||
func (rc *Recovery) Setup() error {
|
||||
rc.Authboss.Core.ViewRenderer.Load(PageRecovery2FA)
|
||||
|
||||
middleware := authboss.MountedMiddleware(rc.Authboss, true, rc.Authboss.Config.Modules.RoutesRedirectOnUnauthed, true, false)
|
||||
rc.Authboss.Core.Router.Get("/2fa/recovery/regen", middleware(rc.Authboss.Core.ErrorHandler.Wrap(rc.GetRegen)))
|
||||
rc.Authboss.Core.Router.Post("/2fa/recovery/regen", middleware(rc.Authboss.Core.ErrorHandler.Wrap(rc.PostRegen)))
|
||||
|
||||
return nil
|
||||
return rc.Authboss.Core.ViewRenderer.Load(PageRecovery2FA)
|
||||
}
|
||||
|
||||
// GetRegen shows a button that enables a user to regen their codes
|
||||
|
@@ -34,8 +34,6 @@ const (
|
||||
PageRecoverEnd = "recover_end"
|
||||
|
||||
recoverInitiateSuccessFlash = "An email has been sent to you with further instructions on how to reset your password."
|
||||
recoverTokenExpiredFlash = "Account recovery request has expired. Please try again."
|
||||
recoverFailedErrorFlash = "Account recovery has failed. Please contact tech support."
|
||||
|
||||
recoverTokenSize = 64
|
||||
recoverTokenSplit = recoverTokenSize / 2
|
||||
|
@@ -50,7 +50,9 @@ func TestRegisterGet(t *testing.T) {
|
||||
ab.Config.Core.Responder = responder
|
||||
|
||||
a := &Register{ab}
|
||||
a.Get(nil, nil)
|
||||
if err := a.Get(nil, nil); err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
|
||||
if responder.Page != PageRegister {
|
||||
t.Error("wanted login page, got:", responder.Page)
|
||||
|
@@ -19,10 +19,6 @@ const (
|
||||
nNonceSize = 32
|
||||
)
|
||||
|
||||
var (
|
||||
errUserMissing = errors.New("user not loaded in callback")
|
||||
)
|
||||
|
||||
func init() {
|
||||
authboss.RegisterModule("remember", &Remember{})
|
||||
}
|
||||
|
Reference in New Issue
Block a user