1.4.5.2
This commit is contained in:
12
EdgeUser/internal/web/actions/default/email/init.go
Normal file
12
EdgeUser/internal/web/actions/default/email/init.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package email
|
||||
|
||||
import "github.com/iwind/TeaGo"
|
||||
|
||||
func init() {
|
||||
TeaGo.BeforeStart(func(server *TeaGo.Server) {
|
||||
server.
|
||||
Prefix("/email").
|
||||
Get("/verify/:code", new(VerifyAction)).
|
||||
EndAll()
|
||||
})
|
||||
}
|
||||
66
EdgeUser/internal/web/actions/default/email/verify.go
Normal file
66
EdgeUser/internal/web/actions/default/email/verify.go
Normal file
@@ -0,0 +1,66 @@
|
||||
// Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
|
||||
|
||||
package email
|
||||
|
||||
import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/configloaders"
|
||||
teaconst "github.com/TeaOSLab/EdgeUser/internal/const"
|
||||
"github.com/TeaOSLab/EdgeUser/internal/web/actions/actionutils"
|
||||
)
|
||||
|
||||
type VerifyAction struct {
|
||||
actionutils.ParentAction
|
||||
}
|
||||
|
||||
func (this *VerifyAction) Init() {
|
||||
this.Nav("", "", "")
|
||||
}
|
||||
|
||||
func (this *VerifyAction) RunGet(params struct {
|
||||
Code string
|
||||
}) {
|
||||
if len(params.Code) == 0 || len(params.Code) > 128 /** 最长不超过128 **/ {
|
||||
this.WriteString("code not found")
|
||||
return
|
||||
}
|
||||
|
||||
// 激活
|
||||
resp, err := this.RPC().UserEmailVerificationRPC().VerifyUserEmail(this.UserContext(), &pb.VerifyUserEmailRequest{
|
||||
Code: params.Code,
|
||||
})
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
|
||||
this.Data["email"] = resp.Email
|
||||
|
||||
if resp.UserId > 0 {
|
||||
this.Data["isOk"] = true
|
||||
|
||||
if this.UserId() > 0 && this.UserId() != resp.UserId {
|
||||
// TODO 暂时不对比当前用户是否一致
|
||||
}
|
||||
} else {
|
||||
this.Data["isOk"] = false
|
||||
this.Data["errorMessage"] = resp.ErrorMessage
|
||||
}
|
||||
|
||||
// 界面
|
||||
config, err := configloaders.LoadUIConfig()
|
||||
if err != nil {
|
||||
this.ErrorPage(err)
|
||||
return
|
||||
}
|
||||
this.Data["systemName"] = config.UserSystemName
|
||||
this.Data["showVersion"] = config.ShowVersion
|
||||
if len(config.Version) > 0 {
|
||||
this.Data["version"] = config.Version
|
||||
} else {
|
||||
this.Data["version"] = teaconst.Version
|
||||
}
|
||||
this.Data["faviconFileId"] = config.FaviconFileId
|
||||
|
||||
this.Show()
|
||||
}
|
||||
Reference in New Issue
Block a user