MCPcopy Index your code
hub / github.com/gogs/gogs / LoginTwoFactorRecoveryCodePost

Function LoginTwoFactorRecoveryCodePost

internal/route/user/auth.go:260–283  ·  view source on GitHub ↗
(c *context.Context)

Source from the content-addressed store, hash-verified

258}
259
260func LoginTwoFactorRecoveryCodePost(c *context.Context) {
261 userID, ok := c.Session.Get("twoFactorUserID").(int64)
262 if !ok {
263 c.NotFound()
264 return
265 }
266
267 if err := database.Handle.TwoFactors().UseRecoveryCode(c.Req.Context(), userID, c.Query("recovery_code")); err != nil {
268 if database.IsTwoFactorRecoveryCodeNotFound(err) {
269 c.Flash.Error(c.Tr("auth.login_two_factor_invalid_recovery_code"))
270 c.RedirectSubpath("/user/login/two_factor_recovery_code")
271 } else {
272 c.Error(err, "use recovery code")
273 }
274 return
275 }
276
277 u, err := database.Handle.Users().GetByID(c.Req.Context(), userID)
278 if err != nil {
279 c.Error(err, "get user by ID")
280 return
281 }
282 afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
283}
284
285func SignOut(c *context.Context) {
286 _ = c.Session.Flush()

Callers

nothing calls this directly

Calls 11

afterLoginFunction · 0.85
UseRecoveryCodeMethod · 0.80
TwoFactorsMethod · 0.80
TrMethod · 0.80
RedirectSubpathMethod · 0.80
UsersMethod · 0.80
GetMethod · 0.65
NotFoundMethod · 0.65
GetByIDMethod · 0.65
ErrorMethod · 0.45

Tested by

no test coverage detected