Skip to content

Conversation

@benbucksch
Copy link
Collaborator

@benbucksch benbucksch commented Dec 23, 2025

There were cases where we did not fill in an OAuth2 config. This is a revision of PR #981.

The automatic account setup failed to fill in the OAuth2 config. Before PR #969, this appeared to work, because the login step would always show the separate window UI, but then the account would be created with the popup window as the default auth UI.

@benbucksch benbucksch self-assigned this Dec 23, 2025
@benbucksch
Copy link
Collaborator Author

Untested so far.

Copy link
Collaborator

@NeilRashbrook NeilRashbrook left a comment

Choose a reason for hiding this comment

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

Would have been r+ without the error in 64c7e5f.

Comment on lines +190 to +191
await onContinue();
return;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is inconsistent with line 168 which doesn't explicitly return (because it's the last code in its block).

Comment on lines +9 to +17
export function getOAuth2BuiltIn(config: Account): WebBasedAuth | undefined {
if (config.protocol == "owa") {
return new OWAAuth(config as OWAAccount);
}
let hostname = (config as TCPAccount).hostname ??
config.url ? new URL(config.url).hostname : null;
let o = OAuth2URLs.find(o => o.hostnames.some(h => h == hostname));
if (!o) {
return undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

config.oAuth2 normally defaults to null.

Also, while I'm here, ?? has higher precedence than ?:, so you'll need to wrap line 14 in ()s.

Comment on lines -83 to +82
if (!this.oAuth2) {
let urls = OAuth2URLs.find(a => a.hostnames.includes(this.hostname));
assert(urls, gt`Could not find OAuth2 config for ${this.hostname}`);
this.oAuth2 = new OAuth2(this, urls.tokenURL, urls.authURL, urls.authDoneURL, urls.scope, urls.clientID, urls.clientSecret, urls.doPKCE);
this.oAuth2.setTokenURLPasswordAuth(urls.tokenURLPasswordAuth);
}
this.oAuth2 ??= getOAuth2BuiltIn(this);
Copy link
Collaborator

Choose a reason for hiding this comment

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

This assert went missing, although one was kept on line 168.

@@ -1,5 +1,5 @@

export function assert(test: boolean | Object | null, errorMessage: string): asserts test {
export function assert(test: boolean | Object | null | undefined, errorMessage: string): asserts test {
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's complaining about this?

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.

3 participants