Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/MHSanaei/3x-ui.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShishkevich D. <135337715+shishkevichd@users.noreply.github.com>2025-05-08 17:20:58 +0300
committerGitHub <noreply@github.com>2025-05-08 17:20:58 +0300
commitfe3b1c9b52f584b0f045907585b206344fed55db (patch)
treeaeef0fa82a0355ee899ec3aecee23045a327a6dc /web/controller/index.go
parentd39ccf4b8f77f99d4468580085e9d89e8b5f0b1c (diff)
chore: implement 2fa auth (#2968)
* chore: implement 2fa auth from #2786 * chore: format code * chore: replace two factor token input with qr-code * chore: requesting confirmation of setting/removing two-factor authentication otpauth library was taken from cdnjs * chore: revert changes in `ClipboardManager` don't need it. * chore: removing twoFactor prop in settings page * chore: remove `twoFactorQr` object in `mounted` function
Diffstat (limited to 'web/controller/index.go')
-rw-r--r--web/controller/index.go17
1 files changed, 8 insertions, 9 deletions
diff --git a/web/controller/index.go b/web/controller/index.go
index 9af4ed7f..c19d1b6e 100644
--- a/web/controller/index.go
+++ b/web/controller/index.go
@@ -14,9 +14,9 @@ import (
)
type LoginForm struct {
- Username string `json:"username" form:"username"`
- Password string `json:"password" form:"password"`
- LoginSecret string `json:"loginSecret" form:"loginSecret"`
+ Username string `json:"username" form:"username"`
+ Password string `json:"password" form:"password"`
+ TwoFactorCode string `json:"twoFactorCode" form:"twoFactorCode"`
}
type IndexController struct {
@@ -37,7 +37,7 @@ func (a *IndexController) initRouter(g *gin.RouterGroup) {
g.GET("/", a.index)
g.POST("/login", a.login)
g.GET("/logout", a.logout)
- g.POST("/getSecretStatus", a.getSecretStatus)
+ g.POST("/getTwoFactorEnable", a.getTwoFactorEnable)
}
func (a *IndexController) index(c *gin.Context) {
@@ -64,14 +64,13 @@ func (a *IndexController) login(c *gin.Context) {
return
}
- user := a.userService.CheckUser(form.Username, form.Password, form.LoginSecret)
+ user := a.userService.CheckUser(form.Username, form.Password, form.TwoFactorCode)
timeStr := time.Now().Format("2006-01-02 15:04:05")
safeUser := template.HTMLEscapeString(form.Username)
safePass := template.HTMLEscapeString(form.Password)
- safeSecret := template.HTMLEscapeString(form.LoginSecret)
if user == nil {
- logger.Warningf("wrong username: \"%s\", password: \"%s\", secret: \"%s\", IP: \"%s\"", safeUser, safePass, safeSecret, getRemoteIp(c))
+ logger.Warningf("wrong username: \"%s\", password: \"%s\", IP: \"%s\"", safeUser, safePass, getRemoteIp(c))
a.tgbot.UserLoginNotify(safeUser, safePass, getRemoteIp(c), timeStr, 0)
pureJsonMsg(c, http.StatusOK, false, I18nWeb(c, "pages.login.toasts.wrongUsernameOrPassword"))
return
@@ -108,8 +107,8 @@ func (a *IndexController) logout(c *gin.Context) {
c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path"))
}
-func (a *IndexController) getSecretStatus(c *gin.Context) {
- status, err := a.settingService.GetSecretStatus()
+func (a *IndexController) getTwoFactorEnable(c *gin.Context) {
+ status, err := a.settingService.GetTwoFactorEnable()
if err == nil {
jsonObj(c, status, nil)
}