Skip to content

Commit

Permalink
fix(oauth2-error): If OAuth2 app is failing then show an indication a…
Browse files Browse the repository at this point in the history
…bout it on the account page
  • Loading branch information
andris9 committed Mar 19, 2024
1 parent 024a686 commit dd44cd5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 10 deletions.
16 changes: 8 additions & 8 deletions lib/mailbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ class Mailbox {
}

async select(skipIdle) {
let lock = await this.getMailboxLock(null, { description: `Select mailbox ${this.path}` });
let lock = await this.getMailboxLock(null, { description: `Select mailbox: ${this.path}` });
// have to release the lock immediatelly, otherwise difficult to process 'exists' / 'expunge' events
lock.release();

Expand Down Expand Up @@ -2075,7 +2075,7 @@ class Mailbox {

let lock;
if (!options.skipLock) {
lock = await this.getMailboxLock(connectionClient, { description: `Get text ${message.uid}` });
lock = await this.getMailboxLock(connectionClient, { description: `Get text: ${message.uid}` });
}

try {
Expand Down Expand Up @@ -2133,7 +2133,7 @@ class Mailbox {
options = options || {};
const connectionClient = await this.connection.getImapConnection(allowSecondary);

let lock = await this.getMailboxLock(connectionClient, { description: `Get attachment ${message.uid}:${part}` });
let lock = await this.getMailboxLock(connectionClient, { description: `Get attachment: ${message.uid}/${part}` });

let streaming = false;
let released = false;
Expand Down Expand Up @@ -2202,7 +2202,7 @@ class Mailbox {
try {
let lock;
if (!options.skipLock) {
lock = await this.getMailboxLock(connectionClient, { description: `Get message ${message.uid}` });
lock = await this.getMailboxLock(connectionClient, { description: `Get message: ${message.uid}` });
}

try {
Expand Down Expand Up @@ -2365,7 +2365,7 @@ class Mailbox {

const connectionClient = await this.connection.getImapConnection(allowSecondary);

let lock = await this.getMailboxLock(connectionClient, { description: `Update message ${message.uid}` });
let lock = await this.getMailboxLock(connectionClient, { description: `Update message: ${message.uid}` });

try {
let result = {};
Expand Down Expand Up @@ -2503,7 +2503,7 @@ class Mailbox {

const connectionClient = await this.connection.getImapConnection(allowSecondary);

let lock = await this.getMailboxLock(connectionClient, { description: `Move message ${message.uid}` });
let lock = await this.getMailboxLock(connectionClient, { description: `Move message: ${message.uid} to: ${target.path}` });

try {
let result = {};
Expand Down Expand Up @@ -2532,7 +2532,7 @@ class Mailbox {

const connectionClient = await this.connection.getImapConnection(allowSecondary);

let lock = await this.getMailboxLock(connectionClient, { description: `Move messages` });
let lock = await this.getMailboxLock(connectionClient, { description: `Move messages to: ${target.path}` });

try {
let result = {};
Expand Down Expand Up @@ -2561,7 +2561,7 @@ class Mailbox {
async deleteMessage(message, force, allowSecondary) {
const connectionClient = await this.connection.getImapConnection(allowSecondary);

let lock = await this.getMailboxLock(connectionClient, { description: `Delete message ${message.uid}` });
let lock = await this.getMailboxLock(connectionClient, { description: `Delete message: ${message.uid}` });

try {
let result = {};
Expand Down
3 changes: 2 additions & 1 deletion lib/oauth/outlook.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const checkForFlags = err => {

if (error === 'invalid_client' && /AADSTS7000222/i.test(description)) {
return {
message: 'OAuth Client Secret for Outlook is either expired or not yet valid'
message: 'OAuth Client Secret for Outlook is either expired or not yet valid',
description
};
}

Expand Down
12 changes: 12 additions & 0 deletions views/accounts/account.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,18 @@
<dd class="col-sm-9">
<a href="/admin/config/oauth/app/{{account.oauth2.app.id}}">{{account.type.comment}}</a>
(<em>{{account.oauth2.app.id}}</em>)

{{#if account.oauth2.app.meta.authFlag}}

<a href="#" tabindex="-1" role="button" data-toggle="popover" data-trigger="hover"
style="dispaly: inline-block;" data-title="OAuth2 application failure"
data-content="{{account.oauth2.app.meta.authFlag.message}}"><i
class="fas fa-exclamation-triangle text-danger"></i></a>


{{/if}}


</dd>
{{else}}
<dd class="col-sm-9">{{account.type.comment}}</dd>
Expand Down
11 changes: 10 additions & 1 deletion views/config/oauth/app.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,16 @@
{{/if}}

{{#if app.meta.authFlag}}
<div class="alert alert-danger">{{app.meta.authFlag.message}}</div>
<div class="alert alert-danger">{{app.meta.authFlag.message}}

{{#if app.meta.authFlag.description}}
<hr>
<p class="mb-0">
<small>{{app.meta.authFlag.description}}</small>
</p>
{{/if}}

</div>
<hr>
{{/if}}

Expand Down

0 comments on commit dd44cd5

Please sign in to comment.