auth.go 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643
  1. package user
  2. import (
  3. gocontext "context"
  4. "encoding/hex"
  5. "net/http"
  6. "net/url"
  7. "time"
  8. "github.com/cockroachdb/errors"
  9. "github.com/flamego/captcha"
  10. "github.com/unknwon/com"
  11. log "unknwon.dev/clog/v2"
  12. "gogs.io/gogs/internal/auth"
  13. "gogs.io/gogs/internal/conf"
  14. "gogs.io/gogs/internal/context"
  15. "gogs.io/gogs/internal/database"
  16. "gogs.io/gogs/internal/email"
  17. "gogs.io/gogs/internal/form"
  18. "gogs.io/gogs/internal/tool"
  19. "gogs.io/gogs/internal/urlutil"
  20. "gogs.io/gogs/internal/userutil"
  21. )
  22. const (
  23. tmplUserAuthLogin = "user/auth/login"
  24. tmplUserAuthTwoFactor = "user/auth/two_factor"
  25. tmplUserAuthTwoFactorRecoveryCode = "user/auth/two_factor_recovery_code"
  26. tmplUserAuthSignup = "user/auth/signup"
  27. TmplUserAuthActivate = "user/auth/activate"
  28. tmplUserAuthForgotPassword = "user/auth/forgot_passwd"
  29. tmplUserAuthResetPassword = "user/auth/reset_passwd"
  30. )
  31. // AutoLogin reads cookie and try to auto-login.
  32. func AutoLogin(c *context.Context) (bool, error) {
  33. if !database.HasEngine {
  34. return false, nil
  35. }
  36. uname := c.GetCookie(conf.Security.CookieUsername)
  37. if uname == "" {
  38. return false, nil
  39. }
  40. isSucceed := false
  41. defer func() {
  42. if !isSucceed {
  43. log.Trace("auto-login cookie cleared: %s", uname)
  44. c.SetCookie(conf.Security.CookieUsername, "", -1, conf.Server.Subpath)
  45. c.SetCookie(conf.Security.CookieRememberName, "", -1, conf.Server.Subpath)
  46. c.SetCookie(conf.Security.LoginStatusCookieName, "", -1, conf.Server.Subpath)
  47. }
  48. }()
  49. u, err := database.Handle.Users().GetByUsername(c.Req.Context(), uname)
  50. if err != nil {
  51. if !database.IsErrUserNotExist(err) {
  52. return false, errors.Newf("get user by name: %v", err)
  53. }
  54. return false, nil
  55. }
  56. if val, ok := c.GetSuperSecureCookie(u.Rands+u.Password, conf.Security.CookieRememberName); !ok || val != u.Name {
  57. return false, nil
  58. }
  59. isSucceed = true
  60. c.Session.Set("uid", u.ID)
  61. c.Session.Set("uname", u.Name)
  62. c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath)
  63. if conf.Security.EnableLoginStatusCookie {
  64. c.SetCookie(conf.Security.LoginStatusCookieName, "true", 0, conf.Server.Subpath)
  65. }
  66. return true, nil
  67. }
  68. func Login(c *context.Context) {
  69. c.Title("sign_in")
  70. // Check auto-login
  71. isSucceed, err := AutoLogin(c)
  72. if err != nil {
  73. c.Error(err, "auto login")
  74. return
  75. }
  76. redirectTo := c.Query("redirect_to")
  77. if len(redirectTo) > 0 {
  78. c.SetCookie("redirect_to", redirectTo, 0, conf.Server.Subpath)
  79. } else {
  80. redirectTo, _ = url.QueryUnescape(c.GetCookie("redirect_to"))
  81. }
  82. if isSucceed {
  83. if urlutil.IsSameSite(redirectTo) {
  84. c.Redirect(redirectTo)
  85. } else {
  86. c.RedirectSubpath("/")
  87. }
  88. c.SetCookie("redirect_to", "", -1, conf.Server.Subpath)
  89. return
  90. }
  91. // Display normal login page
  92. loginSources, err := database.Handle.LoginSources().List(c.Req.Context(), database.ListLoginSourceOptions{OnlyActivated: true})
  93. if err != nil {
  94. c.Error(err, "list activated login sources")
  95. return
  96. }
  97. c.Data["LoginSources"] = loginSources
  98. for i := range loginSources {
  99. if loginSources[i].IsDefault {
  100. c.Data["DefaultLoginSource"] = loginSources[i]
  101. c.Data["login_source"] = loginSources[i].ID
  102. break
  103. }
  104. }
  105. c.Success(tmplUserAuthLogin)
  106. }
  107. func afterLogin(c *context.Context, u *database.User, remember bool) {
  108. if remember {
  109. days := 86400 * conf.Security.LoginRememberDays
  110. c.SetCookie(conf.Security.CookieUsername, u.Name, days, conf.Server.Subpath, "", conf.Security.CookieSecure, true)
  111. c.SetSuperSecureCookie(u.Rands+u.Password, conf.Security.CookieRememberName, u.Name, days, conf.Server.Subpath, "", conf.Security.CookieSecure, true)
  112. }
  113. c.Session.Set("uid", u.ID)
  114. c.Session.Set("uname", u.Name)
  115. c.Session.Delete("twoFactorRemember")
  116. c.Session.Delete("twoFactorUserID")
  117. // Clear whatever CSRF has right now, force to generate a new one
  118. c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath)
  119. if conf.Security.EnableLoginStatusCookie {
  120. c.SetCookie(conf.Security.LoginStatusCookieName, "true", 0, conf.Server.Subpath)
  121. }
  122. redirectTo, _ := url.QueryUnescape(c.GetCookie("redirect_to"))
  123. c.SetCookie("redirect_to", "", -1, conf.Server.Subpath)
  124. if urlutil.IsSameSite(redirectTo) {
  125. c.Redirect(redirectTo)
  126. return
  127. }
  128. c.RedirectSubpath("/")
  129. }
  130. func LoginPost(c *context.Context, f form.SignIn) {
  131. c.Title("sign_in")
  132. loginSources, err := database.Handle.LoginSources().List(c.Req.Context(), database.ListLoginSourceOptions{OnlyActivated: true})
  133. if err != nil {
  134. c.Error(err, "list activated login sources")
  135. return
  136. }
  137. c.Data["LoginSources"] = loginSources
  138. if c.HasError() {
  139. c.Success(tmplUserAuthLogin)
  140. return
  141. }
  142. u, err := database.Handle.Users().Authenticate(c.Req.Context(), f.UserName, f.Password, f.LoginSource)
  143. if err != nil {
  144. switch {
  145. case auth.IsErrBadCredentials(err):
  146. c.FormErr("UserName", "Password")
  147. c.RenderWithErr(c.Tr("form.username_password_incorrect"), tmplUserAuthLogin, &f)
  148. case database.IsErrLoginSourceMismatch(err):
  149. c.FormErr("LoginSource")
  150. c.RenderWithErr(c.Tr("form.auth_source_mismatch"), tmplUserAuthLogin, &f)
  151. default:
  152. c.Error(err, "authenticate user")
  153. }
  154. for i := range loginSources {
  155. if loginSources[i].IsDefault {
  156. c.Data["DefaultLoginSource"] = loginSources[i]
  157. break
  158. }
  159. }
  160. return
  161. }
  162. if !database.Handle.TwoFactors().IsEnabled(c.Req.Context(), u.ID) {
  163. afterLogin(c, u, f.Remember)
  164. return
  165. }
  166. c.Session.Set("twoFactorRemember", f.Remember)
  167. c.Session.Set("twoFactorUserID", u.ID)
  168. c.RedirectSubpath("/user/login/two_factor")
  169. }
  170. func LoginTwoFactor(c *context.Context) {
  171. _, ok := c.Session.Get("twoFactorUserID").(int64)
  172. if !ok {
  173. c.NotFound()
  174. return
  175. }
  176. c.Success(tmplUserAuthTwoFactor)
  177. }
  178. func LoginTwoFactorPost(c *context.Context) {
  179. userID, ok := c.Session.Get("twoFactorUserID").(int64)
  180. if !ok {
  181. c.NotFound()
  182. return
  183. }
  184. t, err := database.Handle.TwoFactors().GetByUserID(c.Req.Context(), userID)
  185. if err != nil {
  186. c.Error(err, "get two factor by user ID")
  187. return
  188. }
  189. passcode := c.Query("passcode")
  190. valid, err := t.ValidateTOTP(passcode)
  191. if err != nil {
  192. c.Error(err, "validate TOTP")
  193. return
  194. } else if !valid {
  195. c.Flash.Error(c.Tr("settings.two_factor_invalid_passcode"))
  196. c.RedirectSubpath("/user/login/two_factor")
  197. return
  198. }
  199. u, err := database.Handle.Users().GetByID(c.Req.Context(), userID)
  200. if err != nil {
  201. c.Error(err, "get user by ID")
  202. return
  203. }
  204. // Prevent same passcode from being reused
  205. if _, err := c.Cache.Get(c.Req.Request.Context(), userutil.TwoFactorCacheKey(u.ID, passcode)); err == nil {
  206. c.Flash.Error(c.Tr("settings.two_factor_reused_passcode"))
  207. c.RedirectSubpath("/user/login/two_factor")
  208. return
  209. }
  210. if err = c.Cache.Set(c.Req.Request.Context(), userutil.TwoFactorCacheKey(u.ID, passcode), 1, 60*time.Second); err != nil {
  211. log.Error("Failed to put cache 'two factor passcode': %v", err)
  212. }
  213. afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
  214. }
  215. func LoginTwoFactorRecoveryCode(c *context.Context) {
  216. _, ok := c.Session.Get("twoFactorUserID").(int64)
  217. if !ok {
  218. c.NotFound()
  219. return
  220. }
  221. c.Success(tmplUserAuthTwoFactorRecoveryCode)
  222. }
  223. func LoginTwoFactorRecoveryCodePost(c *context.Context) {
  224. userID, ok := c.Session.Get("twoFactorUserID").(int64)
  225. if !ok {
  226. c.NotFound()
  227. return
  228. }
  229. if err := database.Handle.TwoFactors().UseRecoveryCode(c.Req.Context(), userID, c.Query("recovery_code")); err != nil {
  230. if database.IsTwoFactorRecoveryCodeNotFound(err) {
  231. c.Flash.Error(c.Tr("auth.login_two_factor_invalid_recovery_code"))
  232. c.RedirectSubpath("/user/login/two_factor_recovery_code")
  233. } else {
  234. c.Error(err, "use recovery code")
  235. }
  236. return
  237. }
  238. u, err := database.Handle.Users().GetByID(c.Req.Context(), userID)
  239. if err != nil {
  240. c.Error(err, "get user by ID")
  241. return
  242. }
  243. afterLogin(c, u, c.Session.Get("twoFactorRemember").(bool))
  244. }
  245. func SignOut(c *context.Context) {
  246. c.Session.Flush()
  247. c.Session.Delete(c.Session.ID())
  248. c.SetCookie(conf.Security.CookieUsername, "", -1, conf.Server.Subpath)
  249. c.SetCookie(conf.Security.CookieRememberName, "", -1, conf.Server.Subpath)
  250. c.SetCookie(conf.Session.CSRFCookieName, "", -1, conf.Server.Subpath)
  251. if conf.Auth.CustomLogoutURL != "" {
  252. c.Redirect(conf.Auth.CustomLogoutURL)
  253. return
  254. }
  255. c.RedirectSubpath("/")
  256. }
  257. func SignUp(c *context.Context) {
  258. c.Title("sign_up")
  259. c.Data["EnableCaptcha"] = conf.Auth.EnableRegistrationCaptcha
  260. if conf.Auth.DisableRegistration {
  261. c.Data["DisableRegistration"] = true
  262. c.Success(tmplUserAuthSignup)
  263. return
  264. }
  265. c.Success(tmplUserAuthSignup)
  266. }
  267. func SignUpPost(c *context.Context, cpt *captcha.Captcha, f form.Register) {
  268. c.Title("sign_up")
  269. c.Data["EnableCaptcha"] = conf.Auth.EnableRegistrationCaptcha
  270. if conf.Auth.DisableRegistration {
  271. c.Status(http.StatusForbidden)
  272. return
  273. }
  274. if c.HasError() {
  275. c.Success(tmplUserAuthSignup)
  276. return
  277. }
  278. if conf.Auth.EnableRegistrationCaptcha {
  279. captchaID := c.Query("captcha_id")
  280. captchaVal := c.Query("captcha")
  281. if !cpt.Verify(captchaID, captchaVal) {
  282. c.FormErr("Captcha")
  283. c.RenderWithErr(c.Tr("form.captcha_incorrect"), tmplUserAuthSignup, &f)
  284. return
  285. }
  286. }
  287. if f.Password != f.Retype {
  288. c.FormErr("Password")
  289. c.RenderWithErr(c.Tr("form.password_not_match"), tmplUserAuthSignup, &f)
  290. return
  291. }
  292. user, err := database.Handle.Users().Create(
  293. c.Req.Context(),
  294. f.UserName,
  295. f.Email,
  296. database.CreateUserOptions{
  297. Password: f.Password,
  298. Activated: !conf.Auth.RequireEmailConfirmation,
  299. },
  300. )
  301. if err != nil {
  302. switch {
  303. case database.IsErrUserAlreadyExist(err):
  304. c.FormErr("UserName")
  305. c.RenderWithErr(c.Tr("form.username_been_taken"), tmplUserAuthSignup, &f)
  306. case database.IsErrEmailAlreadyUsed(err):
  307. c.FormErr("Email")
  308. c.RenderWithErr(c.Tr("form.email_been_used"), tmplUserAuthSignup, &f)
  309. case database.IsErrNameNotAllowed(err):
  310. c.FormErr("UserName")
  311. c.RenderWithErr(c.Tr("user.form.name_not_allowed", err.(database.ErrNameNotAllowed).Value()), tmplUserAuthSignup, &f)
  312. default:
  313. c.Error(err, "create user")
  314. }
  315. return
  316. }
  317. log.Trace("Account created: %s", user.Name)
  318. // FIXME: Count has pretty bad performance implication in large instances, we
  319. // should have a dedicate method to check whether the "user" table is empty.
  320. //
  321. // Auto-set admin for the only user.
  322. if database.Handle.Users().Count(c.Req.Context()) == 1 {
  323. v := true
  324. err := database.Handle.Users().Update(
  325. c.Req.Context(),
  326. user.ID,
  327. database.UpdateUserOptions{
  328. IsActivated: &v,
  329. IsAdmin: &v,
  330. },
  331. )
  332. if err != nil {
  333. c.Error(err, "update user")
  334. return
  335. }
  336. }
  337. // Send confirmation email.
  338. if conf.Auth.RequireEmailConfirmation && user.ID > 1 {
  339. email.SendActivateAccountMail(c, database.NewMailerUser(user))
  340. c.Data["IsSendRegisterMail"] = true
  341. c.Data["Email"] = user.Email
  342. c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60
  343. c.Success(TmplUserAuthActivate)
  344. if err := c.Cache.Set(c.Req.Request.Context(), userutil.MailResendCacheKey(user.ID), 1, time.Duration(180)*time.Second); err != nil {
  345. log.Error("Failed to put cache key 'mail resend': %v", err)
  346. }
  347. return
  348. }
  349. c.RedirectSubpath("/user/login")
  350. }
  351. // parseUserFromCode returns user by username encoded in code.
  352. // It returns nil if code or username is invalid.
  353. func parseUserFromCode(code string) (user *database.User) {
  354. if len(code) <= tool.TimeLimitCodeLength {
  355. return nil
  356. }
  357. // Use tail hex username to query user
  358. hexStr := code[tool.TimeLimitCodeLength:]
  359. if b, err := hex.DecodeString(hexStr); err == nil {
  360. if user, err = database.Handle.Users().GetByUsername(gocontext.TODO(), string(b)); user != nil {
  361. return user
  362. } else if !database.IsErrUserNotExist(err) {
  363. log.Error("Failed to get user by name %q: %v", string(b), err)
  364. }
  365. }
  366. return nil
  367. }
  368. // verify active code when active account
  369. func verifyUserActiveCode(code string) (user *database.User) {
  370. minutes := conf.Auth.ActivateCodeLives
  371. if user = parseUserFromCode(code); user != nil {
  372. // time limit code
  373. prefix := code[:tool.TimeLimitCodeLength]
  374. data := com.ToStr(user.ID) + user.Email + user.LowerName + user.Password + user.Rands
  375. if tool.VerifyTimeLimitCode(data, minutes, prefix) {
  376. return user
  377. }
  378. }
  379. return nil
  380. }
  381. // verify active code when active account
  382. func verifyActiveEmailCode(code, email string) *database.EmailAddress {
  383. minutes := conf.Auth.ActivateCodeLives
  384. if user := parseUserFromCode(code); user != nil {
  385. // time limit code
  386. prefix := code[:tool.TimeLimitCodeLength]
  387. data := com.ToStr(user.ID) + email + user.LowerName + user.Password + user.Rands
  388. if tool.VerifyTimeLimitCode(data, minutes, prefix) {
  389. emailAddress, err := database.Handle.Users().GetEmail(gocontext.TODO(), user.ID, email, false)
  390. if err == nil {
  391. return emailAddress
  392. }
  393. }
  394. }
  395. return nil
  396. }
  397. func Activate(c *context.Context) {
  398. code := c.Query("code")
  399. if code == "" {
  400. c.Data["IsActivatePage"] = true
  401. if c.User.IsActive {
  402. c.NotFound()
  403. return
  404. }
  405. // Resend confirmation email.
  406. if conf.Auth.RequireEmailConfirmation {
  407. if _, err := c.Cache.Get(c.Req.Request.Context(), userutil.MailResendCacheKey(c.User.ID)); err == nil {
  408. c.Data["ResendLimited"] = true
  409. } else {
  410. c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60
  411. email.SendActivateAccountMail(c, database.NewMailerUser(c.User))
  412. if err := c.Cache.Set(c.Req.Request.Context(), userutil.MailResendCacheKey(c.User.ID), 1, time.Duration(180)*time.Second); err != nil {
  413. log.Error("Failed to put cache key 'mail resend': %v", err)
  414. }
  415. }
  416. } else {
  417. c.Data["ServiceNotEnabled"] = true
  418. }
  419. c.Success(TmplUserAuthActivate)
  420. return
  421. }
  422. // Verify code.
  423. if user := verifyUserActiveCode(code); user != nil {
  424. v := true
  425. err := database.Handle.Users().Update(
  426. c.Req.Context(),
  427. user.ID,
  428. database.UpdateUserOptions{
  429. GenerateNewRands: true,
  430. IsActivated: &v,
  431. },
  432. )
  433. if err != nil {
  434. c.Error(err, "update user")
  435. return
  436. }
  437. log.Trace("User activated: %s", user.Name)
  438. c.Session.Set("uid", user.ID)
  439. c.Session.Set("uname", user.Name)
  440. c.RedirectSubpath("/")
  441. return
  442. }
  443. c.Data["IsActivateFailed"] = true
  444. c.Success(TmplUserAuthActivate)
  445. }
  446. func ActivateEmail(c *context.Context) {
  447. code := c.Query("code")
  448. emailAddr := c.Query("email")
  449. // Verify code.
  450. if email := verifyActiveEmailCode(code, emailAddr); email != nil {
  451. err := database.Handle.Users().MarkEmailActivated(c.Req.Context(), email.UserID, email.Email)
  452. if err != nil {
  453. c.Error(err, "activate email")
  454. return
  455. }
  456. log.Trace("Email activated: %s", email.Email)
  457. c.Flash.Success(c.Tr("settings.add_email_success"))
  458. }
  459. c.RedirectSubpath("/user/settings/email")
  460. }
  461. func ForgotPasswd(c *context.Context) {
  462. c.Title("auth.forgot_password")
  463. if !conf.Email.Enabled {
  464. c.Data["IsResetDisable"] = true
  465. c.Success(tmplUserAuthForgotPassword)
  466. return
  467. }
  468. c.Data["IsResetRequest"] = true
  469. c.Success(tmplUserAuthForgotPassword)
  470. }
  471. func ForgotPasswdPost(c *context.Context) {
  472. c.Title("auth.forgot_password")
  473. if !conf.Email.Enabled {
  474. c.Status(403)
  475. return
  476. }
  477. c.Data["IsResetRequest"] = true
  478. emailAddr := c.Query("email")
  479. c.Data["Email"] = emailAddr
  480. u, err := database.Handle.Users().GetByEmail(c.Req.Context(), emailAddr)
  481. if err != nil {
  482. if database.IsErrUserNotExist(err) {
  483. c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60
  484. c.Data["IsResetSent"] = true
  485. c.Success(tmplUserAuthForgotPassword)
  486. return
  487. }
  488. c.Error(err, "get user by email")
  489. return
  490. }
  491. if !u.IsLocal() {
  492. c.FormErr("Email")
  493. c.RenderWithErr(c.Tr("auth.non_local_account"), tmplUserAuthForgotPassword, nil)
  494. return
  495. }
  496. if _, err := c.Cache.Get(c.Req.Request.Context(), userutil.MailResendCacheKey(u.ID)); err == nil {
  497. c.Data["ResendLimited"] = true
  498. c.Success(tmplUserAuthForgotPassword)
  499. return
  500. }
  501. email.SendResetPasswordMail(c, database.NewMailerUser(u))
  502. if err = c.Cache.Set(c.Req.Request.Context(), userutil.MailResendCacheKey(u.ID), 1, time.Duration(180)*time.Second); err != nil {
  503. log.Error("Failed to put cache key 'mail resend': %v", err)
  504. }
  505. c.Data["Hours"] = conf.Auth.ActivateCodeLives / 60
  506. c.Data["IsResetSent"] = true
  507. c.Success(tmplUserAuthForgotPassword)
  508. }
  509. func ResetPasswd(c *context.Context) {
  510. c.Title("auth.reset_password")
  511. code := c.Query("code")
  512. if code == "" {
  513. c.NotFound()
  514. return
  515. }
  516. c.Data["Code"] = code
  517. c.Data["IsResetForm"] = true
  518. c.Success(tmplUserAuthResetPassword)
  519. }
  520. func ResetPasswdPost(c *context.Context) {
  521. c.Title("auth.reset_password")
  522. code := c.Query("code")
  523. if code == "" {
  524. c.NotFound()
  525. return
  526. }
  527. c.Data["Code"] = code
  528. if u := verifyUserActiveCode(code); u != nil {
  529. // Validate password length.
  530. password := c.Query("password")
  531. if len(password) < 6 {
  532. c.Data["IsResetForm"] = true
  533. c.Data["Err_Password"] = true
  534. c.RenderWithErr(c.Tr("auth.password_too_short"), tmplUserAuthResetPassword, nil)
  535. return
  536. }
  537. err := database.Handle.Users().Update(c.Req.Context(), u.ID, database.UpdateUserOptions{Password: &password})
  538. if err != nil {
  539. c.Error(err, "update user")
  540. return
  541. }
  542. log.Trace("User password reset: %s", u.Name)
  543. c.RedirectSubpath("/user/login")
  544. return
  545. }
  546. c.Data["IsResetFailed"] = true
  547. c.Success(tmplUserAuthResetPassword)
  548. }