mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-06 05:30:05 +00:00
Web 服务
This commit is contained in:
45
cmd/dashboard/controller/guest_page.go
Normal file
45
cmd/dashboard/controller/guest_page.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package controller
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/p14yground/nezha/pkg/mygin"
|
||||
"github.com/p14yground/nezha/service/dao"
|
||||
"golang.org/x/oauth2"
|
||||
"golang.org/x/oauth2/github"
|
||||
)
|
||||
|
||||
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{
|
||||
oauth2Config: &oauth2.Config{
|
||||
ClientID: dao.Conf.GitHub.ClientID,
|
||||
ClientSecret: dao.Conf.GitHub.ClientSecret,
|
||||
Scopes: []string{},
|
||||
Endpoint: github.Endpoint,
|
||||
},
|
||||
r: gr,
|
||||
}
|
||||
oauth.serve()
|
||||
}
|
||||
|
||||
func (gp *guestPage) login(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "page/login", mygin.CommonEnvironment(c, gin.H{
|
||||
"Title": "登录",
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user