package controllers import ( "context" "git.golem15.com/golem15/sm-user-plugin/classes" "git.golem15.com/golem15/summercms/modules/backpack" ) // CheckLoginGates consults the published *classes.LoginGates for a // first-factor sign-in that already succeeded and returns its answer: nil, // nil allows the sign-in, a result replaces the token response, and an error // must fail the sign-in closed (answer the opaque 500, issue no token). It // looks the registry up on every call and allows the sign-in when none is // published. Password Login calls it; a social-login plugin calls it before // it issues a token. func CheckLoginGates(ctx context.Context, app *backpack.App, a classes.LoginAttempt) (*classes.LoginGateResult, error) { if app == nil { return nil, nil } gates, ok := app.Lookup[*classes.LoginGates]() if !ok || gates == nil { return nil, nil } return gates.Check(ctx, a) }