更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+35 -20
View File
@@ -12,7 +12,6 @@ import (
beego "github.com/beego/beego/v2/server/web"
)
// AppAuthController App移动端认证控制器
type AppAuthController struct {
beego.Controller
}
@@ -22,7 +21,6 @@ func (c *AppAuthController) serveJSON(data map[string]interface{}) {
_ = c.ServeJSON()
}
// LoginBackend App端登录(需要租户)
func (c *AppAuthController) LoginBackend() {
var req struct {
TenantName string `json:"tenant_name"`
@@ -81,7 +79,6 @@ func (c *AppAuthController) LoginBackend() {
})
}
// GetCurrentUser App端当前登录用户信息,需 Bearer Token
func (c *AppAuthController) GetCurrentUser() {
claims, err := identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend, identity.EndApp)
if err != nil {
@@ -90,7 +87,6 @@ func (c *AppAuthController) GetCurrentUser() {
return
}
// 令牌 user_id 是认证中心 identity_id,需换算成本租户的老 uid 再查老表
uid := services.ResolveTenantUID(uint64(claims.TenantId), uint64(claims.UserID))
var tenantUser models.SystemTenantUser
err = models.Orm.QueryTable(new(models.SystemTenantUser)).
@@ -130,9 +126,6 @@ func (c *AppAuthController) GetCurrentUser() {
})
}
// UpdateCurrentUserProfile 修改当前用户资料(姓名 / 邮箱)。
// 手机号由微信验证并作为登录账号,不开放修改;同步统一身份与当前企业绑定表,
// 避免下次登录或切换企业后又读到旧的姓名。
func (c *AppAuthController) UpdateCurrentUserProfile() {
claims, err := identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend, identity.EndApp)
if err != nil {
@@ -168,8 +161,6 @@ func (c *AppAuthController) UpdateCurrentUserProfile() {
}
uid := services.ResolveTenantUID(uint64(claims.TenantId), uint64(claims.UserID))
// 尚未加入企业(tid=0)的新注册用户没有老表行,属正常情况;
// 姓名仍写入统一身份,工作台首页直接读它显示。
_, err = models.Orm.QueryTable(new(models.SystemTenantUser)).
Filter("uid", uid).
Filter("tid", claims.TenantId).
@@ -193,7 +184,6 @@ func (c *AppAuthController) UpdateCurrentUserProfile() {
})
}
// SendLoginCode 发送App端登录验证码
func (c *AppAuthController) SendLoginCode() {
var req struct {
Account string `json:"account"`
@@ -234,7 +224,6 @@ func (c *AppAuthController) SendLoginCode() {
c.serveJSON(map[string]interface{}{"code": 200, "msg": "验证码已发送"})
}
// LoginBySms App端手机号验证码登录(占位实现)
func (c *AppAuthController) LoginBySms() {
c.serveJSON(map[string]interface{}{
"code": 501,
@@ -242,7 +231,6 @@ func (c *AppAuthController) LoginBySms() {
})
}
// Logout App端退出登录(当前为无状态直接返回成功)
func (c *AppAuthController) Logout() {
c.serveJSON(map[string]interface{}{
"code": 200,
@@ -250,7 +238,6 @@ func (c *AppAuthController) Logout() {
})
}
// GetGeetest3Infos 获取App端极验3.0配置
func (c *AppAuthController) GetGeetest3Infos() {
cfg, _ := models.GetPlatformLoginVerify()
if cfg.Geetest3ID == nil || cfg.Geetest3Key == nil {
@@ -267,7 +254,6 @@ func (c *AppAuthController) GetGeetest3Infos() {
})
}
// GetGeetest4Infos 获取App端极验4.0配置
func (c *AppAuthController) GetGeetest4Infos() {
cfg, _ := models.GetPlatformLoginVerify()
if cfg.Geetest4ID == nil || cfg.Geetest4Key == nil {
@@ -284,7 +270,6 @@ func (c *AppAuthController) GetGeetest4Infos() {
})
}
// GetOpenVerify 判断是否开启App端登录验证
func (c *AppAuthController) GetOpenVerify() {
cfg, _ := models.GetPlatformLoginVerify()
openVerify := "0"
@@ -307,7 +292,6 @@ func (c *AppAuthController) GetOpenVerify() {
})
}
// VerifyAccount 验证租户和账号是否存在(忘记密码第一步)
func (c *AppAuthController) VerifyAccount() {
var req struct {
TenantName string `json:"tenant_name"`
@@ -343,7 +327,6 @@ func (c *AppAuthController) VerifyAccount() {
})
}
// SendResetCode 发送找回密码验证码(忘记密码第二步)
func (c *AppAuthController) SendResetCode() {
var req struct {
TenantName string `json:"tenant_name"`
@@ -381,7 +364,6 @@ func (c *AppAuthController) SendResetCode() {
})
}
// ResetPassword 重置密码(忘记密码第三步)
func (c *AppAuthController) ResetPassword() {
var req struct {
TenantName string `json:"tenant_name"`
@@ -416,7 +398,41 @@ func (c *AppAuthController) ResetPassword() {
})
}
// Register App端注册(占位实现)
func (c *AppAuthController) ChangePassword() {
var req struct {
OldPassword string `json:"old_password"`
NewPassword string `json:"new_password"`
ConfirmPassword string `json:"confirm_password"`
}
body := c.Ctx.Input.RequestBody
if len(body) == 0 {
var err error
body, err = io.ReadAll(c.Ctx.Request.Body)
if err != nil || len(body) == 0 {
c.serveJSON(map[string]interface{}{"code": 400, "msg": "参数错误"})
return
}
}
if err := json.Unmarshal(body, &req); err != nil {
c.serveJSON(map[string]interface{}{"code": 400, "msg": "参数错误"})
return
}
claims, err := identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndApp, identity.EndBackend)
if err != nil {
c.serveJSON(map[string]interface{}{"code": 401, "msg": "登录已失效,请重新登录"})
return
}
if err := services.ChangeIdentityPassword(uint64(claims.UserID), req.OldPassword, req.NewPassword, req.ConfirmPassword); err != nil {
c.serveJSON(map[string]interface{}{"code": 400, "msg": err.Error()})
return
}
c.serveJSON(map[string]interface{}{"code": 200, "msg": "密码修改成功"})
}
func (c *AppAuthController) Register() {
c.serveJSON(map[string]interface{}{
"code": 501,
@@ -424,7 +440,6 @@ func (c *AppAuthController) Register() {
})
}
// SendRegisterCode 发送App端注册验证码(占位实现)
func (c *AppAuthController) SendRegisterCode() {
c.serveJSON(map[string]interface{}{
"code": 501,