|
|
@@ -23,11 +23,11 @@ export class AuthService {
|
|
|
userAgent?: string;
|
|
|
appVersion?: string;
|
|
|
os?: string;
|
|
|
- uChannelId?: string;
|
|
|
+ channelId?: string;
|
|
|
machine?: string;
|
|
|
// plus whatever you need like account, password, etc.
|
|
|
}): Promise<any> {
|
|
|
- const { uid, ip, userAgent, appVersion, os, uChannelId, machine } = params;
|
|
|
+ const { uid, ip, userAgent, appVersion, os, channelId, machine } = params;
|
|
|
|
|
|
// 1) Your existing auth logic (validate user, etc.)
|
|
|
// const user = await this.validateUser(...);
|
|
|
@@ -38,25 +38,25 @@ export class AuthService {
|
|
|
const now = Date.now(); // number (ms since epoch)
|
|
|
|
|
|
const user = await this.getUserByUid(uid);
|
|
|
- const firstChannel = await this.getChannelById(uChannelId || '');
|
|
|
- // if user does not exist, uChannelId = firstChannel.channelId
|
|
|
- let finalUChannelId = uChannelId;
|
|
|
+ const firstChannel = await this.getChannelById(channelId || '');
|
|
|
+ // if user does not exist, channelId = firstChannel.channelId
|
|
|
+ let finalchannelId = channelId;
|
|
|
if (!user && firstChannel) {
|
|
|
- finalUChannelId = firstChannel.channelId;
|
|
|
+ finalchannelId = firstChannel.channelId;
|
|
|
}
|
|
|
// if user exists, take firstChannel.channelId
|
|
|
else if (user && firstChannel) {
|
|
|
- finalUChannelId = firstChannel.channelId;
|
|
|
+ finalchannelId = firstChannel.channelId;
|
|
|
}
|
|
|
|
|
|
// Build JWT payload with required and optional tracking fields.
|
|
|
- // Tracking fields (uChannelId, machine, ip, userAgent, appVersion, os) are optional
|
|
|
+ // Tracking fields (channelId, machine, ip, userAgent, appVersion, os) are optional
|
|
|
// to preserve backward compatibility with older tokens and minimize JWT size for stability.
|
|
|
const payload: AppJwtPayload = {
|
|
|
sub: uid,
|
|
|
uid,
|
|
|
jti: tokenId,
|
|
|
- uChannelId: finalUChannelId,
|
|
|
+ channelId: finalchannelId,
|
|
|
machine,
|
|
|
ip,
|
|
|
userAgent,
|
|
|
@@ -74,7 +74,7 @@ export class AuthService {
|
|
|
userAgent,
|
|
|
appVersion,
|
|
|
os,
|
|
|
- uChannelId: finalUChannelId,
|
|
|
+ channelId: finalchannelId,
|
|
|
machine,
|
|
|
tokenId,
|
|
|
loginAt: now,
|