Some tweaks
This commit is contained in:
parent
5d86c8d6ab
commit
c3052dd8ca
@ -191,6 +191,7 @@ import {
|
||||
folderFill,
|
||||
funnel,
|
||||
gear,
|
||||
google,
|
||||
grid,
|
||||
gripVertical,
|
||||
hash,
|
||||
@ -201,6 +202,7 @@ import {
|
||||
link,
|
||||
listTask,
|
||||
listUl,
|
||||
microsoft,
|
||||
nodePlus,
|
||||
pencil,
|
||||
people,
|
||||
@ -295,6 +297,7 @@ const icons = {
|
||||
folderFill,
|
||||
funnel,
|
||||
gear,
|
||||
google,
|
||||
grid,
|
||||
gripVertical,
|
||||
hash,
|
||||
@ -305,6 +308,7 @@ const icons = {
|
||||
link,
|
||||
listTask,
|
||||
listUl,
|
||||
microsoft,
|
||||
nodePlus,
|
||||
pencil,
|
||||
people,
|
||||
|
@ -13,8 +13,16 @@
|
||||
<button type="button" class="btn btn-sm btn-outline-primary ms-4" (click)="editMailAccount()" *pngxIfPermissions="{ action: PermissionAction.Add, type: PermissionType.MailAccount }">
|
||||
<i-bs name="plus-circle"></i-bs> <ng-container i18n>Add Account</ng-container>
|
||||
</button>
|
||||
<a class="btn btn-sm btn-outline-primary ms-2" [href]="gmailOAuthUrl" i18n>Connect with Gmail</a>
|
||||
<a class="btn btn-sm btn-outline-primary ms-2" [href]="outlookOAuthUrl" i18n>Connect with Outlook</a>
|
||||
@if (gmailOAuthUrl) {
|
||||
<a class="btn btn-sm btn-outline-secondary ms-2" [href]="gmailOAuthUrl">
|
||||
<i-bs name="google"></i-bs> <ng-container i18n>Connect Gmail Account</ng-container>
|
||||
</a>
|
||||
}
|
||||
@if (outlookOAuthUrl) {
|
||||
<a class="btn btn-sm btn-outline-secondary ms-2" [href]="outlookOAuthUrl">
|
||||
<i-bs name="microsoft"></i-bs> <ng-container i18n>Connect Outlook Account</ng-container>
|
||||
</a>
|
||||
}
|
||||
</h4>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
|
@ -38,7 +38,7 @@ export class MailComponent
|
||||
oAuthAccoundId: number
|
||||
|
||||
public get gmailOAuthUrl(): string {
|
||||
return this.settingsService.get(SETTINGS_KEYS.GOOGLE_OAUTH_URL)
|
||||
return this.settingsService.get(SETTINGS_KEYS.GMAIL_OAUTH_URL)
|
||||
}
|
||||
|
||||
public get outlookOAuthUrl(): string {
|
||||
@ -94,6 +94,9 @@ export class MailComponent
|
||||
|
||||
this.route.queryParamMap.subscribe((params) => {
|
||||
if (params.get('oauth_success')) {
|
||||
const success = params.get('oauth_success') === '1'
|
||||
if (success) {
|
||||
this.toastService.showInfo($localize`OAuth2 authentication success`)
|
||||
this.oAuthAccoundId = parseInt(params.get('account_id'))
|
||||
if (this.mailAccounts.length > 0) {
|
||||
this.editMailAccount(
|
||||
@ -102,6 +105,11 @@ export class MailComponent
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
this.toastService.showError(
|
||||
$localize`OAuth2 authentication failed, see logs for details`
|
||||
)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ export const SETTINGS_KEYS = {
|
||||
SEARCH_DB_ONLY: 'general-settings:search:db-only',
|
||||
SEARCH_FULL_TYPE: 'general-settings:search:more-link',
|
||||
EMPTY_TRASH_DELAY: 'trash_delay',
|
||||
GOOGLE_OAUTH_URL: 'google_oauth_url',
|
||||
GMAIL_OAUTH_URL: 'gmail_oauth_url',
|
||||
OUTLOOK_OAUTH_URL: 'outlook_oauth_url',
|
||||
}
|
||||
|
||||
@ -245,7 +245,7 @@ export const SETTINGS: UiSetting[] = [
|
||||
default: 30,
|
||||
},
|
||||
{
|
||||
key: SETTINGS_KEYS.GOOGLE_OAUTH_URL,
|
||||
key: SETTINGS_KEYS.GMAIL_OAUTH_URL,
|
||||
type: 'string',
|
||||
default: '',
|
||||
},
|
||||
|
@ -1566,7 +1566,6 @@ class UiSettingsView(GenericAPIView):
|
||||
return url
|
||||
|
||||
def generate_outlook_oauth_url(self) -> str:
|
||||
# https://login.microsoftonline.com/common/oauth2/v2.0/authorize ?
|
||||
token_request_uri = (
|
||||
"https://login.microsoftonline.com/common/oauth2/v2.0/authorize"
|
||||
)
|
||||
@ -1608,7 +1607,7 @@ class UiSettingsView(GenericAPIView):
|
||||
ui_settings["auditlog_enabled"] = settings.AUDIT_LOG_ENABLED
|
||||
|
||||
if settings.GMAIL_OAUTH_ENABLED:
|
||||
ui_settings["google_oauth_url"] = self.generate_gmail_oauth_url()
|
||||
ui_settings["gmail_oauth_url"] = self.generate_gmail_oauth_url()
|
||||
|
||||
if settings.OUTLOOK_OAUTH_ENABLED:
|
||||
ui_settings["outlook_oauth_url"] = self.generate_outlook_oauth_url()
|
||||
@ -2225,7 +2224,9 @@ class OauthCallbackView(GenericAPIView):
|
||||
|
||||
if "error" in data:
|
||||
logger.error(f"Error {response.status_code} getting access token: {data}")
|
||||
return HttpResponseBadRequest(data["error"])
|
||||
return HttpResponseRedirect(
|
||||
"http://localhost:4200/mail?oauth_success=0",
|
||||
)
|
||||
elif "access_token" in data:
|
||||
access_token = data["access_token"]
|
||||
# if "refresh_token" in data:
|
||||
@ -2237,7 +2238,6 @@ class OauthCallbackView(GenericAPIView):
|
||||
imap_server=imap_server,
|
||||
defaults=defaults,
|
||||
)
|
||||
|
||||
return HttpResponseRedirect(
|
||||
f"http://localhost:4200/mail?oauth_success=1&account_id={account.pk}",
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user