Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

token retrieval without init #102

Merged
merged 27 commits into from
Sep 3, 2024

Conversation

ashleysmithTTD
Copy link
Contributor

No description provided.

@ashleysmithTTD ashleysmithTTD changed the title initial testing for token retrieval without init token retrieval without init Aug 27, 2024
@ashleysmithTTD ashleysmithTTD marked this pull request as draft August 27, 2024 20:08
'Expected getAdvertisingToken() returns undefined and isLoginRequired() returns undefined',
};
},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This state was only used in one test, and isn't really relevant anymore since an advertising token can be found without init

}
return null;
}

Copy link
Contributor Author

@ashleysmithTTD ashleysmithTTD Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spoke with Lionell about making this a separate function from loadIdentityFromCookie in the CookieManager since we don't want them doing any setting (including migrating and setting the legacy cookie) without init, just getting

return decodeURIComponent(payload.split('=')[1]);
}
}
return getCookie(this._cookieName);
Copy link
Contributor Author

@ashleysmithTTD ashleysmithTTD Aug 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure if this is conventional or not to have these two functions be the same name - one inside the class and one outside the class - happy to change the name if needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love it. It obviously works but it adds a little extra confusion.

@ashleysmithTTD ashleysmithTTD marked this pull request as ready for review August 30, 2024 22:20
this._opts.useCookie === false &&
this._localStorageManager.loadIdentityFromLocalStorage()
) {
if (!this._opts.useCookie && this._localStorageManager.loadIdentityFromLocalStorage()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this._opts.useCookie will always be false here. It's checking for true and returning above on line 61.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can also be undefined and if it is undefined, we would still want the cookie to be removed I believe

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure. but above it's checking if (this._opts.useCookie) so if (!this._opts.useCookie) will necessarily be true at this point in the code. The previous code was specifically looking for 'false.' If you just remove the check it should also execute when undefined.

!hasExpired(this._identity.refresh_expires)
)
private temporarilyUnavailable(identity: Identity | OptoutIdentity | null | undefined) {
if (!identity && this._apiClient?.hasActiveRequests()) return true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you just put a comment in here indicating that this means that the identity is expired but refreshable? Might help the next person.

return decodeURIComponent(payload.split('=')[1]);
}
}
return getCookie(this._cookieName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love it. It obviously works but it adds a little extra confusion.

@ashleysmithTTD ashleysmithTTD merged commit 302e76c into main Sep 3, 2024
3 checks passed
@ashleysmithTTD ashleysmithTTD deleted the ans-UID2-3578-allow-token-retrieval-without-init branch September 3, 2024 21:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants