提交 b1bf12a2 编写于 作者: 雪洛's avatar 雪洛 提交者: chenruilong

fix: refresh token error

(cherry picked from commit ec58d6a0)
上级 f1e775b1
...@@ -4,6 +4,8 @@ const word = { ...@@ -4,6 +4,8 @@ const word = {
} }
const sentence = { const sentence = {
'uni-id-token-expired': '登录状态失效,token已过期',
'uni-id-check-token-failed': 'token校验未通过',
'uni-id-account-exists': '此账号已注册', 'uni-id-account-exists': '此账号已注册',
'uni-id-account-not-exists': '此账号未注册', 'uni-id-account-not-exists': '此账号未注册',
'uni-id-account-not-exists-in-current-app': '此账号未在该应用注册', 'uni-id-account-not-exists-in-current-app': '此账号未在该应用注册',
......
...@@ -194,12 +194,18 @@ async function postLogin (params = {}) { ...@@ -194,12 +194,18 @@ async function postLogin (params = {}) {
last_login_ip: clientIP, last_login_ip: clientIP,
...extraData ...extraData
} }
const createTokenRes = await this.uniIdCommon.createToken({
uid
})
const { const {
errCode,
token, token,
tokenExpired tokenExpired
} = await this.uniIdCommon.createToken({ } = createTokenRes
uid if (errCode) {
}) throw createTokenRes
}
if (uniIdToken) { if (uniIdToken) {
try { try {
......
...@@ -157,7 +157,7 @@ async function postRegister (params = {}) { ...@@ -157,7 +157,7 @@ async function postRegister (params = {}) {
if (uniIdToken) { if (uniIdToken) {
try { try {
await logout.call(this) await logout.call(this)
} catch (error) {} } catch (error) { }
} }
const beforeRegister = this.hooks.beforeRegister const beforeRegister = this.hooks.beforeRegister
...@@ -173,12 +173,19 @@ async function postRegister (params = {}) { ...@@ -173,12 +173,19 @@ async function postRegister (params = {}) {
id: uid id: uid
} = await userCollection.add(userRecord) } = await userCollection.add(userRecord)
const createTokenRes = await this.uniIdCommon.createToken({
uid
})
const { const {
errCode,
token, token,
tokenExpired tokenExpired
} = await this.uniIdCommon.createToken({ } = createTokenRes
uid
}) if (errCode) {
throw createTokenRes
}
await this.middleware.uniIdLog({ await this.middleware.uniIdLog({
data: { data: {
......
...@@ -3,12 +3,17 @@ ...@@ -3,12 +3,17 @@
* @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#refresh-token * @tutorial https://uniapp.dcloud.net.cn/uniCloud/uni-id-pages.html#refresh-token
*/ */
module.exports = async function () { module.exports = async function () {
const refreshTokenRes = await this.uniIdCommon.refreshToken({
token: this.getUniversalUniIdToken()
})
const { const {
errCode,
token, token,
tokenExpired tokenExpired
} = await this.uniIdCommon.refreshToken({ } = refreshTokenRes
token: this.getUniversalUniIdToken() if (errCode) {
}) throw refreshTokenRes
}
return { return {
errCode: 0, errCode: 0,
newToken: { newToken: {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册