chore: enable forcetypeassert linter, fix issues (#38804)

Enable [`forcetypeassert`](https://github.com/gostaticanalysis/forcetypeassert)
linter to prevent unchecked type assertions. ~650 issues fixed, most
fixes were clean, some use `setting.PanicInDevOrTesting`.

The only behaviour changes are where code would previously send a 500 error
or panic, a 4xx error is now emitted.

Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
silverwind
2026-08-09 10:25:06 +00:00
committed by GitHub
co-authored by wxiaoguang
parent fac8bf2eca
commit 76a81b24f9
248 changed files with 1110 additions and 995 deletions
+4 -3
View File
@@ -31,12 +31,13 @@ func WebAuthn(ctx *context.Context) {
}
// Ensure user is in a 2FA session.
if ctx.Session.Get("twofaUid") == nil {
idSess, ok := ctx.Session.Get("twofaUid").(int64)
if !ok {
ctx.ServerError("UserSignIn", errors.New("not in WebAuthn session"))
return
}
hasTwoFactor, err := auth.HasTwoFactorByUID(ctx, ctx.Session.Get("twofaUid").(int64))
hasTwoFactor, err := auth.HasTwoFactorByUID(ctx, idSess)
if err != nil {
ctx.ServerError("HasTwoFactorByUID", err)
return
@@ -265,7 +266,7 @@ func WebAuthnLoginAssertionPost(ctx *context.Context) {
return
}
remember := ctx.Session.Get("twofaRemember").(bool)
remember := ctx.Session.Get("twofaRemember").(bool) //nolint:forcetypeassert // must exist
handleSignInFull(ctx, user, remember)
_ = ctx.Session.Delete("twofaUid")
ctx.JSONRedirect(consumeAuthRedirectLink(ctx))