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

fix: refresh token error

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