mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-04-19 21:42:24 +00:00
tgbot - login notify (show password for failed login)
This commit is contained in:
parent
b84e3ef338
commit
21b64beb96
10 changed files with 20 additions and 11 deletions
|
@ -65,13 +65,13 @@ func (a *IndexController) login(c *gin.Context) {
|
||||||
user := a.userService.CheckUser(form.Username, form.Password, form.LoginSecret)
|
user := a.userService.CheckUser(form.Username, form.Password, form.LoginSecret)
|
||||||
timeStr := time.Now().Format("2006-01-02 15:04:05")
|
timeStr := time.Now().Format("2006-01-02 15:04:05")
|
||||||
if user == nil {
|
if user == nil {
|
||||||
logger.Warningf("wrong username or password: \"%s\" \"%s\"", form.Username, form.Password)
|
logger.Warningf("wrong username or password or secret: \"%s\" \"%s\" \"%s\"", form.Username, form.Password, form.LoginSecret)
|
||||||
a.tgbot.UserLoginNotify(form.Username, getRemoteIp(c), timeStr, 0)
|
a.tgbot.UserLoginNotify(form.Username, form.Password, getRemoteIp(c), timeStr, 0)
|
||||||
pureJsonMsg(c, http.StatusOK, false, I18nWeb(c, "pages.login.toasts.wrongUsernameOrPassword"))
|
pureJsonMsg(c, http.StatusOK, false, I18nWeb(c, "pages.login.toasts.wrongUsernameOrPassword"))
|
||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
logger.Infof("%s login success, Ip Address: %s\n", form.Username, getRemoteIp(c))
|
logger.Infof("%s Successful Login, Ip Address: %s\n", form.Username, getRemoteIp(c))
|
||||||
a.tgbot.UserLoginNotify(form.Username, getRemoteIp(c), timeStr, 1)
|
a.tgbot.UserLoginNotify(form.Username, ``, getRemoteIp(c), timeStr, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
sessionMaxAge, err := a.settingService.GetSessionMaxAge()
|
sessionMaxAge, err := a.settingService.GetSessionMaxAge()
|
||||||
|
@ -87,14 +87,14 @@ func (a *IndexController) login(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
err = session.SetLoginUser(c, user)
|
err = session.SetLoginUser(c, user)
|
||||||
logger.Info("user", user.Id, "login success")
|
logger.Info("user ", user.Id, " login success")
|
||||||
jsonMsg(c, I18nWeb(c, "pages.login.toasts.successLogin"), err)
|
jsonMsg(c, I18nWeb(c, "pages.login.toasts.successLogin"), err)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (a *IndexController) logout(c *gin.Context) {
|
func (a *IndexController) logout(c *gin.Context) {
|
||||||
user := session.GetLoginUser(c)
|
user := session.GetLoginUser(c)
|
||||||
if user != nil {
|
if user != nil {
|
||||||
logger.Info("user", user.Id, "logout")
|
logger.Info("user ", user.Id, " logout")
|
||||||
}
|
}
|
||||||
session.ClearSession(c)
|
session.ClearSession(c)
|
||||||
c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path"))
|
c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path"))
|
||||||
|
|
|
@ -1019,7 +1019,7 @@ func (t *Tgbot) prepareServerUsageInfo() string {
|
||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
|
|
||||||
func (t *Tgbot) UserLoginNotify(username string, ip string, time string, status LoginStatus) {
|
func (t *Tgbot) UserLoginNotify(username string, password string, ip string, time string, status LoginStatus) {
|
||||||
if !t.IsRunning() {
|
if !t.IsRunning() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -1037,11 +1037,12 @@ func (t *Tgbot) UserLoginNotify(username string, ip string, time string, status
|
||||||
msg := ""
|
msg := ""
|
||||||
if status == LoginSuccess {
|
if status == LoginSuccess {
|
||||||
msg += t.I18nBot("tgbot.messages.loginSuccess")
|
msg += t.I18nBot("tgbot.messages.loginSuccess")
|
||||||
|
msg += t.I18nBot("tgbot.messages.hostname", "Hostname=="+hostname)
|
||||||
} else if status == LoginFail {
|
} else if status == LoginFail {
|
||||||
msg += t.I18nBot("tgbot.messages.loginFailed")
|
msg += t.I18nBot("tgbot.messages.loginFailed")
|
||||||
|
msg += t.I18nBot("tgbot.messages.hostname", "Hostname=="+hostname)
|
||||||
|
msg += t.I18nBot("tgbot.messages.password", "Password=="+password)
|
||||||
}
|
}
|
||||||
|
|
||||||
msg += t.I18nBot("tgbot.messages.hostname", "Hostname=="+hostname)
|
|
||||||
msg += t.I18nBot("tgbot.messages.username", "Username=="+username)
|
msg += t.I18nBot("tgbot.messages.username", "Username=="+username)
|
||||||
msg += t.I18nBot("tgbot.messages.ip", "IP=="+ip)
|
msg += t.I18nBot("tgbot.messages.ip", "IP=="+ip)
|
||||||
msg += t.I18nBot("tgbot.messages.time", "Time=="+time)
|
msg += t.I18nBot("tgbot.messages.time", "Time=="+time)
|
||||||
|
|
|
@ -78,7 +78,7 @@
|
||||||
"invalidFormData" = "The Input data format is invalid."
|
"invalidFormData" = "The Input data format is invalid."
|
||||||
"emptyUsername" = "Username is required"
|
"emptyUsername" = "Username is required"
|
||||||
"emptyPassword" = "Password is required"
|
"emptyPassword" = "Password is required"
|
||||||
"wrongUsernameOrPassword" = "Invalid username or password."
|
"wrongUsernameOrPassword" = "Invalid username or password or secret."
|
||||||
"successLogin" = "Login"
|
"successLogin" = "Login"
|
||||||
|
|
||||||
[pages.index]
|
[pages.index]
|
||||||
|
@ -544,7 +544,7 @@
|
||||||
"selectUserFailed" = "❌ Error in user selection!"
|
"selectUserFailed" = "❌ Error in user selection!"
|
||||||
"userSaved" = "✅ Telegram User saved."
|
"userSaved" = "✅ Telegram User saved."
|
||||||
"loginSuccess" = "✅ Logged in to the panel successfully.\r\n"
|
"loginSuccess" = "✅ Logged in to the panel successfully.\r\n"
|
||||||
"loginFailed" = "❗️ Log in to the panel failed.\r\n"
|
"loginFailed" = "❗️Login attempt to the panel failed.\r\n"
|
||||||
"report" = "🕰 Scheduled Reports: {{ .RunTime }}\r\n"
|
"report" = "🕰 Scheduled Reports: {{ .RunTime }}\r\n"
|
||||||
"datetime" = "⏰ Date&Time: {{ .DateTime }}\r\n"
|
"datetime" = "⏰ Date&Time: {{ .DateTime }}\r\n"
|
||||||
"hostname" = "💻 Host: {{ .Hostname }}\r\n"
|
"hostname" = "💻 Host: {{ .Hostname }}\r\n"
|
||||||
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 Traffic: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 Traffic: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Status: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Status: {{ .State }}\r\n"
|
||||||
"username" = "👤 Username: {{ .Username }}\r\n"
|
"username" = "👤 Username: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 Password: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ Time: {{ .Time }}\r\n"
|
"time" = "⏰ Time: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 Port: {{ .Port }}\r\n"
|
"port" = "🔌 Port: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -560,6 +560,7 @@
|
||||||
"traffic" = "🚦 Tráfico: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 Tráfico: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Estado de Xray: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Estado de Xray: {{ .State }}\r\n"
|
||||||
"username" = "👤 Nombre de usuario: {{ .Username }}\r\n"
|
"username" = "👤 Nombre de usuario: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 Contraseña: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ Hora: {{ .Time }}\r\n"
|
"time" = "⏰ Hora: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 Puerto: {{ .Port }}\r\n"
|
"port" = "🔌 Puerto: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 ترافیک: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 ترافیک: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ وضعیتایکسری: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ وضعیتایکسری: {{ .State }}\r\n"
|
||||||
"username" = "👤 نامکاربری: {{ .Username }}\r\n"
|
"username" = "👤 نامکاربری: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 رمز عبور: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ زمان: {{ .Time }}\r\n"
|
"time" = "⏰ زمان: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 نامورودی: {{ .Remark }}\r\n"
|
"inbound" = "📍 نامورودی: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 پورت: {{ .Port }}\r\n"
|
"port" = "🔌 پورت: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 Lalu Lintas: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 Lalu Lintas: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Status: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Status: {{ .State }}\r\n"
|
||||||
"username" = "👤 Nama Pengguna: {{ .Username }}\r\n"
|
"username" = "👤 Nama Pengguna: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 Kata Sandi: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ Waktu: {{ .Time }}\r\n"
|
"time" = "⏰ Waktu: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 Port: {{ .Port }}\r\n"
|
"port" = "🔌 Port: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 Трафик: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 Трафик: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Состояние Xray: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Состояние Xray: {{ .State }}\r\n"
|
||||||
"username" = "👤 Имя пользователя: {{ .Username }}\r\n"
|
"username" = "👤 Имя пользователя: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 Пароль: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ Время: {{ .Time }}\r\n"
|
"time" = "⏰ Время: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 Входящий поток: {{ .Remark }}\r\n"
|
"inbound" = "📍 Входящий поток: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 Трафік: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 Трафік: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Статус: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Статус: {{ .State }}\r\n"
|
||||||
"username" = "👤 Ім'я користувача: {{ .Username }}\r\n"
|
"username" = "👤 Ім'я користувача: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 Пароль: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ Час: {{ .Time }}\r\n"
|
"time" = "⏰ Час: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
"port" = "🔌 Порт: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 Lưu lượng: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 Lưu lượng: {{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Trạng thái Xray: {{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Trạng thái Xray: {{ .State }}\r\n"
|
||||||
"username" = "👤 Tên người dùng: {{ .Username }}\r\n"
|
"username" = "👤 Tên người dùng: {{ .Username }}\r\n"
|
||||||
|
"password" = "👤 Mật khẩu: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ Thời gian: {{ .Time }}\r\n"
|
"time" = "⏰ Thời gian: {{ .Time }}\r\n"
|
||||||
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
"inbound" = "📍 Inbound: {{ .Remark }}\r\n"
|
||||||
"port" = "🔌 Cổng: {{ .Port }}\r\n"
|
"port" = "🔌 Cổng: {{ .Port }}\r\n"
|
||||||
|
|
|
@ -562,6 +562,7 @@
|
||||||
"traffic" = "🚦 流量:{{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
"traffic" = "🚦 流量:{{ .Total }} (↑{{ .Upload }},↓{{ .Download }})\r\n"
|
||||||
"xrayStatus" = "ℹ️ Xray 状态:{{ .State }}\r\n"
|
"xrayStatus" = "ℹ️ Xray 状态:{{ .State }}\r\n"
|
||||||
"username" = "👤 用户名:{{ .Username }}\r\n"
|
"username" = "👤 用户名:{{ .Username }}\r\n"
|
||||||
|
"password" = "👤 密码: {{ .Password }}\r\n"
|
||||||
"time" = "⏰ 时间:{{ .Time }}\r\n"
|
"time" = "⏰ 时间:{{ .Time }}\r\n"
|
||||||
"inbound" = "📍 入站:{{ .Remark }}\r\n"
|
"inbound" = "📍 入站:{{ .Remark }}\r\n"
|
||||||
"port" = "🔌 端口:{{ .Port }}\r\n"
|
"port" = "🔌 端口:{{ .Port }}\r\n"
|
||||||
|
|
Loading…
Reference in a new issue