(c *context.Context)
| 258 | } |
| 259 | |
| 260 | func 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 | |
| 285 | func SignOut(c *context.Context) { |
| 286 | _ = c.Session.Flush() |
nothing calls this directly
no test coverage detected