Commit 1277fb20 authored by ThinhNC's avatar ThinhNC

fix: auth service with login, registration, token rotation, and session management

parent 73855b03
...@@ -503,12 +503,16 @@ export class AuthService { ...@@ -503,12 +503,16 @@ export class AuthService {
resolvedPhone = resolvedPhone.replace(/^\+84/, '0').replace(/^84/, '0'); resolvedPhone = resolvedPhone.replace(/^\+84/, '0').replace(/^84/, '0');
} }
// Đảm bảo có Zalo ID làm mã định danh // Đảm bảo luôn có Zalo ID làm mã định danh tài khoản
if (!zaloId) { if (!zaloId) {
if (resolvedPhone) { if (resolvedPhone) {
zaloId = `zalo_${resolvedPhone}`; zaloId = `zalo_${resolvedPhone}`;
} else if (dto.phoneToken) {
const tokenHash = crypto.createHash('sha256').update(dto.phoneToken).digest('hex').substring(0, 16);
zaloId = `zalo_tok_${tokenHash}`;
} else { } else {
throw new AppError('Unable to identify Zalo user. Please grant basic permissions.', 400, ERROR_CODE.VALIDATION_ERROR); const accHash = crypto.createHash('sha256').update(accessToken).digest('hex').substring(0, 16);
zaloId = `zalo_acc_${accHash}`;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment