用户端不要强制用户输入手机号
This commit is contained in:
@@ -1059,7 +1059,8 @@ export class AuthService {
|
||||
include: { avatar: true },
|
||||
});
|
||||
|
||||
if (user?.phone && user.phoneVerifiedAt) {
|
||||
// 微信登录不再强制绑定手机号;phoneVerified=false 也可签发会话,下单页仅提示可选绑定
|
||||
if (user) {
|
||||
let activeUser: UserRow =
|
||||
guestId && guestId !== user.id ? await this.mergeUsers(guestId, user.id) : (user as UserRow);
|
||||
activeUser = await this.prisma.user.update({
|
||||
@@ -1087,7 +1088,7 @@ export class AuthService {
|
||||
if (guestId) {
|
||||
try {
|
||||
const guest = await this.assertActiveUser(guestId);
|
||||
if (guest.phoneVerifiedAt && !guest.wxOpenId) {
|
||||
if (!guest.wxOpenId) {
|
||||
const activeUser = await this.attachWechatToUser(guest.id, session, clientApp, platform);
|
||||
return this.buildSessionResponse(activeUser, clientApp, activeUser.deviceKey);
|
||||
}
|
||||
@@ -1096,36 +1097,34 @@ export class AuthService {
|
||||
}
|
||||
}
|
||||
|
||||
const wxSessionKey = randomUUID();
|
||||
await this.redis.setJson(
|
||||
`wx:session:${wxSessionKey}`,
|
||||
{
|
||||
openId: session.openId,
|
||||
unionId: session.unionId,
|
||||
sessionKey: 'sessionKey' in session ? session.sessionKey : undefined,
|
||||
accessToken: session.accessToken,
|
||||
clientApp,
|
||||
guestId: guestId?.toString(),
|
||||
} satisfies WxSessionPayload,
|
||||
1800,
|
||||
);
|
||||
|
||||
if (user && !user.phoneVerifiedAt) {
|
||||
return {
|
||||
needBindPhone: true,
|
||||
wxSessionKey,
|
||||
actorType: 'USER',
|
||||
actorId: user.id.toString(),
|
||||
phoneVerified: false,
|
||||
user: this.formatUserProfile(user),
|
||||
};
|
||||
let created = await this.prisma.user.create({
|
||||
data: {
|
||||
userNo: generateUserNo(),
|
||||
wxOpenId: session.openId,
|
||||
wxUnionId: session.unionId,
|
||||
nickname: '微信用户',
|
||||
cityPreference: {
|
||||
create: {
|
||||
selectedCityCode: '410100',
|
||||
selectedDistrict: '郑州市',
|
||||
},
|
||||
},
|
||||
},
|
||||
include: { avatar: true },
|
||||
});
|
||||
if (session.accessToken) {
|
||||
const synced = await this.syncWechatUserProfile(created.id, session.accessToken, session.openId);
|
||||
if (synced) created = synced as UserRow;
|
||||
}
|
||||
|
||||
return {
|
||||
needBindPhone: true,
|
||||
wxSessionKey,
|
||||
phoneVerified: false,
|
||||
};
|
||||
this.analyticsService.trackOneSafe(created.id, clientApp, {
|
||||
eventName: 'wechat_login',
|
||||
extraJson: { platform },
|
||||
});
|
||||
this.analyticsService.trackOneSafe(created.id, clientApp, {
|
||||
eventName: 'login_success',
|
||||
extraJson: { method: 'wechat', platform },
|
||||
});
|
||||
return this.buildSessionResponse(created, clientApp, created.deviceKey);
|
||||
}
|
||||
|
||||
async bindWechatPhone(
|
||||
|
||||
Reference in New Issue
Block a user