更新密码找回uniapp
This commit is contained in:
1 parent
7f9a66da0f
commit
3fdda89833
1304 files changed
+3503
-26132
No files matched your search
@@ -10,18 +10,6 @@ import (
|
||||
"server/models"
|
||||
)
|
||||
|
||||
// =============================================================
|
||||
// 移动端免登录票据
|
||||
//
|
||||
// 背景:移动端用「密码直连」拿到的是 client_id=yz-uniapp、user_type=app 的令牌,
|
||||
// Web 端(管理后台)只认自己 localStorage 里 client_id=yz-backend 的令牌,
|
||||
// 两者登录态不共享,导致移动端打开 webview 时又要走一遍统一认证登录。
|
||||
//
|
||||
// 方案:移动端令牌 → 一次性票据 → Web 端令牌。
|
||||
// 票据本身是一次性的短时效凭证,即使泄露也无法二次使用。
|
||||
// =============================================================
|
||||
|
||||
// AppTicketTTL 票据有效期。移动端拿到后应立即跳转,不需要长时效。
|
||||
const AppTicketTTL = 60 * time.Second
|
||||
|
||||
var (
|
||||
@@ -30,7 +18,6 @@ var (
|
||||
ErrAppTicketExpired = errors.New("登录票据已过期")
|
||||
)
|
||||
|
||||
// CreateAppTicket 签发一次性票据
|
||||
func CreateAppTicket(identityID, tid uint64, clientID string) (string, error) {
|
||||
if identityID == 0 {
|
||||
return "", errors.New("身份无效")
|
||||
@@ -56,7 +43,6 @@ func CreateAppTicket(identityID, tid uint64, clientID string) (string, error) {
|
||||
return ticket, nil
|
||||
}
|
||||
|
||||
// ConsumeAppTicket 核销一次性票据(CAS 防重放),返回票据携带的身份与租户。
|
||||
func ConsumeAppTicket(ticket string) (*models.AuthAppLoginTicket, error) {
|
||||
ticket = strings.TrimSpace(ticket)
|
||||
if ticket == "" {
|
||||
@@ -89,7 +75,6 @@ func ConsumeAppTicket(ticket string) (*models.AuthAppLoginTicket, error) {
|
||||
return &row, nil
|
||||
}
|
||||
|
||||
// PurgeExpiredAppTickets 清理过期票据(防止表无限增长,由调用方定期触发)
|
||||
func PurgeExpiredAppTickets() (int64, error) {
|
||||
return models.Orm.QueryTable(new(models.AuthAppLoginTicket)).
|
||||
Filter("expire_at__lt", time.Now().Add(-24*time.Hour)).
|
||||
|
||||
Reference in new issue
Block a user