nezha/cmd/dashboard/controller/guest_page.go

48 lines
965 B
Go
Raw Normal View History

2019-12-08 03:59:58 -05:00
package controller
import (
"net/http"
"github.com/gin-gonic/gin"
2022-01-08 22:54:14 -05:00
"github.com/naiba/nezha/model"
2020-11-10 21:07:45 -05:00
"github.com/naiba/nezha/pkg/mygin"
2022-01-08 22:54:14 -05:00
"github.com/naiba/nezha/service/singleton"
2019-12-08 03:59:58 -05:00
)
type guestPage struct {
r *gin.Engine
}
func (gp *guestPage) serve() {
gr := gp.r.Group("")
gr.Use(mygin.Authorize(mygin.AuthorizeOption{
Guest: true,
IsPage: true,
Msg: "您已登录",
Btn: "返回首页",
Redirect: "/",
}))
gr.GET("/login", gp.login)
oauth := &oauth2controller{
r: gr,
}
oauth.serve()
}
func (gp *guestPage) login(c *gin.Context) {
LoginType := "GitHub"
RegistrationLink := "https://github.com/join"
2022-01-08 22:54:14 -05:00
if singleton.Conf.Oauth2.Type == model.ConfigTypeGitee {
LoginType = "Gitee"
RegistrationLink = "https://gitee.com/signup"
}
2020-12-09 06:05:40 -05:00
c.HTML(http.StatusOK, "dashboard/login", mygin.CommonEnvironment(c, gin.H{
"Title": "登录",
"LoginType": LoginType,
"RegistrationLink": RegistrationLink,
2019-12-08 03:59:58 -05:00
}))
}