Small improvements for #1645

This commit is contained in:
the-djmaze 2024-07-01 12:09:49 +02:00
parent 7f7ee97106
commit 139d3e6651
2 changed files with 12 additions and 5 deletions

View file

@ -1,10 +1,10 @@
(rl => {
const client_id = rl.pluginSettingsGet('login-gmail', 'client_id'),
const client_id = rl.pluginSettingsGet('login-o365', 'client_id'),
login = () => {
document.location = 'https://login.microsoftonline.com/common/oauth2/v2.0/authorize?' + (new URLSearchParams({
response_type: 'code',
client_id: client_id,
redirect_uri: document.location.href + '?LoginGMail',
redirect_uri: document.location.href + '?LoginO365',
scope: [
// Associate personal info
'openid',
@ -19,7 +19,7 @@
'https://outlook.office.com/IMAP.AccessAsUser.All'
*/
].join(' '),
state: 'gmail', // + rl.settings.app('token') + localStorage.getItem('smctoken')
state: 'o365', // + rl.settings.app('token') + localStorage.getItem('smctoken')
// Force authorize screen, so we always get a refresh_token
access_type: 'offline',
prompt: 'consent'
@ -28,7 +28,7 @@
if (client_id) {
addEventListener('sm-user-login', e => {
if (event.detail.get('Email').includes('@gmail.com')) {
if (event.detail.get('Email').includes('@hotmail.com')) {
e.preventDefault();
login();
}

View file

@ -4,6 +4,10 @@
* I'm not going to pay, so feel free to fix this code yourself.
* https://learn.microsoft.com/en-us/exchange/client-developer/legacy-protocols/how-to-authenticate-an-imap-pop-smtp-application-by-using-oauth
* https://answers.microsoft.com/en-us/msoffice/forum/all/configuration-for-imap-pop-and-smtp-with-oauth-in/3db47d43-25ac-4e0b-b957-22585e6caf15
*
* https://portal.azure.com/#view/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/~/RegisteredApps
*
* redirect_uri=https://{DOMAIN}/?LoginO365
*/
use RainLoop\Model\MainAccount;
@ -153,7 +157,10 @@ class LoginO365Plugin extends \RainLoop\Plugins\AbstractPlugin
\RainLoop\Plugins\Property::NewInstance('client_secret')
->SetLabel('Client Secret')
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING)
->SetEncrypted()
->SetEncrypted(),
\RainLoop\Plugins\Property::NewInstance('tenant_id')
->SetLabel('Tenant ID')
->SetType(\RainLoop\Enumerations\PluginPropertyType::STRING)
];
}