Skip to content

Commit

Permalink
fix(outlook-api): Falls back to username as account email if failed t…
Browse files Browse the repository at this point in the history
…o retrieve account email address
  • Loading branch information
andris9 committed Nov 1, 2024
1 parent 4140e34 commit 57f3d82
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion lib/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
const logger = require('./logger');
const Boom = require('@hapi/boom');
const msgpack = require('msgpack5')();
const { normalizePath, formatAccountListingResponse, unpackUIDRangeForSearch, mergeObjects, download, resolveCredentials } = require('./tools');
const { normalizePath, formatAccountListingResponse, unpackUIDRangeForSearch, mergeObjects, download, resolveCredentials, isEmail } = require('./tools');
const crypto = require('crypto');
const { MessageChannel } = require('worker_threads');
const { MessagePortReadable } = require('./message-port-stream');
Expand Down Expand Up @@ -343,6 +343,11 @@ class Account {
result.account = null;
}

// falls back to oauth2 username as the email address if email address is not set
if (!result.email && result?.oauth2?.auth?.user && isEmail(result?.oauth2?.auth?.user)) {
result.email = result.oauth2.auth.user;
}

result.counters = counters;

return result;
Expand Down
2 changes: 1 addition & 1 deletion workers/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1978,7 +1978,7 @@ const init = async () => {
}
}

if (!userInfo.email && userInfo.username) {
if (!userInfo.email && userInfo.username && isEmail(userInfo.username)) {
userInfo.email = userInfo.username;
}

Expand Down

0 comments on commit 57f3d82

Please sign in to comment.