| | |
| | | }; |
| | | await this.userInfoEntity.insert(user); |
| | | } |
| | | return this.token({ id: user.id }); |
| | | return this.token({ id: user.unionid }); |
| | | } |
| | | |
| | | /** |
| | |
| | | const find: any = { openid: wxUserInfo.openid }; |
| | | let wxInfo: any = await this.userWxEntity.findOneBy(find); |
| | | if (wxInfo) { |
| | | wxUserInfo.id = wxInfo.id; |
| | | wxUserInfo.id = wxInfo.unionid; |
| | | } |
| | | return this.userWxEntity.save({ |
| | | ...wxUserInfo, |
| | |
| | | }; |
| | | await this.userInfoEntity.insert(userInfo); |
| | | } |
| | | return this.token({ id: userInfo.id }); |
| | | return this.token({ id: userInfo.unionid }); |
| | | } |
| | | |
| | | /** |
| | |
| | | const userInfo = await this.userInfoEntity.findOneBy({ |
| | | id: info['id'], |
| | | }); |
| | | return this.token({ id: userInfo.id }); |
| | | return this.token({ id: userInfo?.unionid }); |
| | | } catch (e) { |
| | | throw new CoolCommException( |
| | | '刷新token失败,请检查refreshToken是否正确或过期' |
| | |
| | | |
| | | if (user && user.password == md5(password)) { |
| | | return this.token({ |
| | | id: user.id, |
| | | id: user.unionid, |
| | | }); |
| | | } else { |
| | | throw new CoolCommException('账号或密码错误'); |
| | |
| | | */ |
| | | async generateToken(info, isRefresh = false) { |
| | | const { expire, refreshExpire, secret } = this.jwtConfig; |
| | | const user = await this.userInfoEntity.findOneBy({ id: Equal(info.id) }); |
| | | const user = await this.userInfoEntity.findOneBy({ unionid: Equal(info.unionid) }); |
| | | const tokenInfo = { |
| | | isRefresh, |
| | | ...info, |
| | |
| | | */ |
| | | async generateSorterToken(info, isRefresh = false) { |
| | | const { expire, refreshExpire, secret } = this.jwtConfig; |
| | | const user = await this.basicdataSorterEntity.findOneBy({ businessId: Equal(info.id) }); |
| | | const user = await this.basicdataSorterEntity.findOneBy({ businessId: Equal(info.unionid) }); |
| | | const tokenInfo = { |
| | | isRefresh, |
| | | ...info, |