Skip to content

Commit 03ffd1b

Browse files
Merge pull request #116 from IABTechLab/ans-UID2-4035-deprecate-is-login-required
Deprecate hasIdentity and replace with isIdentityAvailable
2 parents e4b05cf + 5c7e420 commit 03ffd1b

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

examples/cstg/html/index.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
$('#login_required').text(
3030
sdk.isLoginRequired() || sdk.isLoginRequired() === undefined ? 'yes' : 'no'
3131
);
32-
$(`#has_opted_out`).text(
33-
sdk.hasOptedOut() ? 'yes' : 'no'
34-
);
32+
$(`#has_opted_out`).text(sdk.hasOptedOut() ? 'yes' : 'no');
3533
$('#update_counter').text(callbackCounter);
3634
$('#identity_state').text(String(JSON.stringify(state, null, 2)));
3735

examples/google-secure-signals-integration/with_sdk_v3/views/login.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!DOCTYPE html>
22
<html>
33
<head>
44
<meta charset="UTF-8" />

src/sdkBase.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -181,16 +181,20 @@ export abstract class SdkBase {
181181
return this._initComplete;
182182
}
183183

184-
/**
185-
* Deprecated
186-
*/
187184
public isLoginRequired() {
188-
return this.hasIdentity();
185+
return !this.isIdentityAvailable();
189186
}
190187

188+
/**
189+
* @deprecated in version 3.10.0. Will remove in June 2025. Use isIdentityAvailable() instead.
190+
**/
191191
public hasIdentity() {
192192
if (!this._initComplete) return undefined;
193-
return !(this.isLoggedIn() || this._apiClient?.hasActiveRequests());
193+
return !(this.isIdentityValid() || this._apiClient?.hasActiveRequests());
194+
}
195+
196+
public isIdentityAvailable() {
197+
return this.isIdentityValid() || this._apiClient?.hasActiveRequests();
194198
}
195199

196200
public hasOptedOut() {
@@ -295,8 +299,9 @@ export abstract class SdkBase {
295299
if (this.hasOptedOut()) this._callbackManager.runCallbacks(EventType.OptoutReceived, {});
296300
}
297301

298-
private isLoggedIn() {
299-
return this._identity && !hasExpired(this._identity.refresh_expires);
302+
private isIdentityValid() {
303+
const identity = this._identity ?? this.getIdentityNoInit();
304+
return identity && !hasExpired(identity.refresh_expires);
300305
}
301306

302307
private temporarilyUnavailable(identity: Identity | OptoutIdentity | null | undefined) {

0 commit comments

Comments
 (0)