67 lines
1.5 KiB
Go
67 lines
1.5 KiB
Go
// 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()
|
|
}
|