更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -17,7 +17,6 @@ type backendAuthLoginRequest struct {
|
||||
Account string `json:"account"`
|
||||
Password string `json:"password"`
|
||||
Code string `json:"code"`
|
||||
// 极验4验证参数
|
||||
CaptchaID string `json:"captcha_id"`
|
||||
LotNumber string `json:"lot_number"`
|
||||
PassToken string `json:"pass_token"`
|
||||
@@ -25,7 +24,6 @@ type backendAuthLoginRequest struct {
|
||||
CaptchaOutput string `json:"captcha_output"`
|
||||
}
|
||||
|
||||
// BackendAuthController backend 端认证控制器
|
||||
type BackendAuthController struct {
|
||||
beego.Controller
|
||||
}
|
||||
@@ -35,14 +33,12 @@ func (c *BackendAuthController) serveJSON(data map[string]interface{}) {
|
||||
_ = c.ServeJSON()
|
||||
}
|
||||
|
||||
// recordLoginLog 记录登录日志(成功/失败均记录,失败不影响登录流程)
|
||||
func (c *BackendAuthController) recordLoginLog(tid *uint64, userID uint64, account, userName, tenantName, loginType string, status int8, message string) {
|
||||
ip := c.Ctx.Input.IP()
|
||||
userAgent := c.Ctx.Request.UserAgent()
|
||||
RecordLoginLog(tid, userID, account, userName, tenantName, loginType, status, message, ip, userAgent)
|
||||
}
|
||||
|
||||
// LoginBackend backend 登录(需要租户)
|
||||
func (c *BackendAuthController) LoginBackend() {
|
||||
var req backendAuthLoginRequest
|
||||
|
||||
@@ -127,7 +123,6 @@ func (c *BackendAuthController) LoginBackend() {
|
||||
})
|
||||
}
|
||||
|
||||
// GetCurrentUser 当前登录 backend 用户信息,需 Bearer Token
|
||||
func (c *BackendAuthController) GetCurrentUser() {
|
||||
claims, err := identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend, identity.EndApp)
|
||||
if err != nil {
|
||||
@@ -162,24 +157,19 @@ func (c *BackendAuthController) GetCurrentUser() {
|
||||
name = strings.TrimSpace(*tenantUser.Name)
|
||||
}
|
||||
|
||||
// 查询当前租户名称
|
||||
tenantName := ""
|
||||
var tenant models.SystemTenant
|
||||
if err := models.Orm.QueryTable(new(models.SystemTenant)).Filter("id", claims.TenantId).One(&tenant); err == nil {
|
||||
tenantName = strings.TrimSpace(tenant.TenantName)
|
||||
}
|
||||
|
||||
// 头像:统一取认证中心身份头像(个人中心上传后写在这里,userinfo 同源)
|
||||
avatar := services.GetIdentityAvatar(tenantUser.Uid)
|
||||
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 200,
|
||||
"msg": "success",
|
||||
"data": map[string]interface{}{
|
||||
// id 统一为认证中心 identity_id,与 /auth/userinfo 保持一致,
|
||||
// 避免同一字段在不同来源(登录回跳 vs 本接口)含义不同
|
||||
"id": claims.UserID,
|
||||
// uid 为老表 yz_system_tenant_user.uid,仅少数按老 uid 存取的场景需要
|
||||
"uid": tenantUser.Uid,
|
||||
"account": account,
|
||||
"name": name,
|
||||
@@ -192,10 +182,6 @@ func (c *BackendAuthController) GetCurrentUser() {
|
||||
})
|
||||
}
|
||||
|
||||
// GetCurrentUserProfile 当前登录用户的角色 / 部门 / 职位
|
||||
// GET /backend/getCurrentUserProfile
|
||||
// 返回 department / position(来自员工档案,按登录账号 + 租户匹配);
|
||||
// 若均无,则回退到角色名(role_name)。
|
||||
func (c *BackendAuthController) GetCurrentUserProfile() {
|
||||
claims, err := identity.Claims(c.Ctx.Request.Header.Get("Authorization"), identity.EndBackend, identity.EndApp)
|
||||
if err != nil {
|
||||
@@ -204,7 +190,6 @@ func (c *BackendAuthController) GetCurrentUserProfile() {
|
||||
return
|
||||
}
|
||||
|
||||
// 同上:令牌 user_id 是 identity_id,需换算成本租户的老 uid
|
||||
uid := services.ResolveTenantUID(uint64(claims.TenantId), uint64(claims.UserID))
|
||||
var tenantUser models.SystemTenantUser
|
||||
if err := models.Orm.QueryTable(new(models.SystemTenantUser)).
|
||||
@@ -224,7 +209,6 @@ func (c *BackendAuthController) GetCurrentUserProfile() {
|
||||
name = strings.TrimSpace(*tenantUser.Name)
|
||||
}
|
||||
|
||||
// 角色名:按 group_id 查询本租户下的租户角色(cid=2)
|
||||
roleName := ""
|
||||
if tenantUser.GroupID > 0 {
|
||||
var role models.AdminRole
|
||||
@@ -237,7 +221,6 @@ func (c *BackendAuthController) GetCurrentUserProfile() {
|
||||
}
|
||||
}
|
||||
|
||||
// 部门 / 职位:来自员工档案,按账号 + 租户匹配
|
||||
department := ""
|
||||
position := ""
|
||||
if account != "" {
|
||||
@@ -256,7 +239,6 @@ func (c *BackendAuthController) GetCurrentUserProfile() {
|
||||
}
|
||||
}
|
||||
|
||||
// 员工档案的 department 字段存的是组织ID,需转换为组织名称展示
|
||||
if department != "" {
|
||||
orgNames := (&BackendEmployeeFileController{}).efOrgNameMap(int(claims.TenantId))
|
||||
department = efOrgNameByID(orgNames, department)
|
||||
@@ -275,7 +257,6 @@ func (c *BackendAuthController) GetCurrentUserProfile() {
|
||||
})
|
||||
}
|
||||
|
||||
// SendLoginCode 发送 backend 登录验证码
|
||||
func (c *BackendAuthController) SendLoginCode() {
|
||||
var req struct {
|
||||
Account string `json:"account"`
|
||||
@@ -316,7 +297,6 @@ func (c *BackendAuthController) SendLoginCode() {
|
||||
c.serveJSON(map[string]interface{}{"code": 200, "msg": "验证码已发送"})
|
||||
}
|
||||
|
||||
// LoginBySms 手机号验证码登录(占位实现)
|
||||
func (c *BackendAuthController) LoginBySms() {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 501,
|
||||
@@ -324,7 +304,6 @@ func (c *BackendAuthController) LoginBySms() {
|
||||
})
|
||||
}
|
||||
|
||||
// Logout backend 退出登录(当前为无状态直接返回成功)
|
||||
func (c *BackendAuthController) Logout() {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 200,
|
||||
@@ -332,7 +311,6 @@ func (c *BackendAuthController) Logout() {
|
||||
})
|
||||
}
|
||||
|
||||
// GetGeetest3Infos 获取 backend 极验3.0配置
|
||||
func (c *BackendAuthController) GetGeetest3Infos() {
|
||||
cfg, _ := models.GetPlatformLoginVerify()
|
||||
if cfg.Geetest3ID == nil || cfg.Geetest3Key == nil {
|
||||
@@ -349,7 +327,6 @@ func (c *BackendAuthController) GetGeetest3Infos() {
|
||||
})
|
||||
}
|
||||
|
||||
// GetGeetest4Infos 获取 backend 极验4.0配置
|
||||
func (c *BackendAuthController) GetGeetest4Infos() {
|
||||
cfg, _ := models.GetPlatformLoginVerify()
|
||||
if cfg.Geetest4ID == nil || cfg.Geetest4Key == nil {
|
||||
@@ -366,7 +343,6 @@ func (c *BackendAuthController) GetGeetest4Infos() {
|
||||
})
|
||||
}
|
||||
|
||||
// GetOpenVerify 判断是否开启 backend 登录验证
|
||||
func (c *BackendAuthController) GetOpenVerify() {
|
||||
cfg, _ := models.GetPlatformLoginVerify()
|
||||
openVerify := "0"
|
||||
@@ -389,7 +365,6 @@ func (c *BackendAuthController) GetOpenVerify() {
|
||||
})
|
||||
}
|
||||
|
||||
// Register 注册(占位实现)
|
||||
func (c *BackendAuthController) Register() {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 501,
|
||||
@@ -397,7 +372,6 @@ func (c *BackendAuthController) Register() {
|
||||
})
|
||||
}
|
||||
|
||||
// SendRegisterCode 发送注册验证码(占位实现)
|
||||
func (c *BackendAuthController) SendRegisterCode() {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 501,
|
||||
@@ -405,7 +379,6 @@ func (c *BackendAuthController) SendRegisterCode() {
|
||||
})
|
||||
}
|
||||
|
||||
// ResetPassword 忘记密码重置(占位实现)
|
||||
func (c *BackendAuthController) ResetPassword() {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 501,
|
||||
@@ -413,7 +386,6 @@ func (c *BackendAuthController) ResetPassword() {
|
||||
})
|
||||
}
|
||||
|
||||
// SendResetCode 发送找回密码验证码(占位实现)
|
||||
func (c *BackendAuthController) SendResetCode() {
|
||||
c.serveJSON(map[string]interface{}{
|
||||
"code": 501,
|
||||
|
||||
Reference in new issue
Block a user