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:
authorMHSanaei <mc.sanaei@gmail.com>2023-02-09 22:18:06 +0300
committerMHSanaei <mc.sanaei@gmail.com>2023-02-09 22:18:06 +0300
commitb73e4173a3c1e69e02ad6b4e3b43e425e57a5be9 (patch)
treed95d2f5e903d97082e11eb9f9023c165b1bde388 /web/controller/base.go
3x-ui
Diffstat (limited to 'web/controller/base.go')
-rw-r--r--web/controller/base.go33
1 files changed, 33 insertions, 0 deletions
diff --git a/web/controller/base.go b/web/controller/base.go
new file mode 100644
index 00000000..6ed2f0ef
--- /dev/null
+++ b/web/controller/base.go
@@ -0,0 +1,33 @@
+package controller
+
+import (
+ "github.com/gin-gonic/gin"
+ "net/http"
+ "x-ui/web/session"
+)
+
+type BaseController struct {
+}
+
+func (a *BaseController) checkLogin(c *gin.Context) {
+ if !session.IsLogin(c) {
+ if isAjax(c) {
+ pureJsonMsg(c, false, I18n(c , "pages.login.loginAgain"))
+ } else {
+ c.Redirect(http.StatusTemporaryRedirect, c.GetString("base_path"))
+ }
+ c.Abort()
+ } else {
+ c.Next()
+ }
+}
+
+
+func I18n(c *gin.Context , name string) string{
+ anyfunc, _ := c.Get("I18n")
+ i18n, _ := anyfunc.(func(key string, params ...string) (string, error))
+
+ message, _ := i18n(name)
+
+ return message;
+}