mirror of
https://github.com/the-djmaze/snappymail.git
synced 2024-11-10 09:02:45 +08:00
Use SNAPPYMAIL_INCLUDE_AS_API and added SSO test
This commit is contained in:
parent
dd6779b1a8
commit
7f084dda53
4 changed files with 29 additions and 8 deletions
|
@ -65,12 +65,12 @@ class SnappyMailHelper {
|
|||
{
|
||||
self::regSnappyMailDataFunction();
|
||||
|
||||
$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
|
||||
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
|
||||
include $sPath;
|
||||
|
||||
if (class_exists('\\SnappyMail\\Api'))
|
||||
if (class_exists('\\RainLoop\\Api'))
|
||||
{
|
||||
$SsoHash = \SnappyMail\Api::GetUserSsoHash($sEmail, $sPassword);
|
||||
$SsoHash = \RainLoop\Api::GetUserSsoHash($sEmail, $sPassword);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -238,10 +238,10 @@ class SnappyMailHelper {
|
|||
|
||||
self::regSnappyMailDataFunction();
|
||||
|
||||
$_ENV['RAINLOOP_INCLUDE_AS_API'] = true;
|
||||
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
|
||||
include $sApiPath;
|
||||
|
||||
\SnappyMail\Api::LogoutCurrentLogginedUser();
|
||||
\RainLoop\Api::LogoutCurrentLogginedUser();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -661,8 +661,8 @@ class ServiceActions
|
|||
$sEmail = \trim($aData['Email']);
|
||||
$sPassword = $aData['Password'];
|
||||
|
||||
$aAdditionalOptions = isset($aData['AdditionalOptions']) && \is_array($aData['AdditionalOptions']) &&
|
||||
\count($aData['AdditionalOptions']) ? $aData['AdditionalOptions'] : null;
|
||||
$aAdditionalOptions = (isset($aData['AdditionalOptions']) && \is_array($aData['AdditionalOptions']))
|
||||
? $aData['AdditionalOptions'] : [];
|
||||
|
||||
try
|
||||
{
|
||||
|
|
|
@ -158,7 +158,7 @@ if (!defined('RAINLOOP_APP_LIBRARIES_PATH')) {
|
|||
if (class_exists('RainLoop\\Api')) {
|
||||
RainLoop\Api::Handle();
|
||||
// NextCloud/OwnCloud?
|
||||
if (empty($_ENV['RAINLOOP_INCLUDE_AS_API'])) {
|
||||
if (empty($_ENV['SNAPPYMAIL_INCLUDE_AS_API'])) {
|
||||
RainLoop\Service::Handle();
|
||||
exit(0);
|
||||
}
|
||||
|
|
21
test/sso.php
Normal file
21
test/sso.php
Normal file
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
// Enable SnappyMail Api and include index file
|
||||
$_ENV['SNAPPYMAIL_INCLUDE_AS_API'] = true;
|
||||
require '../index.php';
|
||||
|
||||
/**
|
||||
* Get SSO hash
|
||||
*/
|
||||
$aAdditionalOptions = array(
|
||||
// One of /snappymail/v/0.0.0/app/localization/*
|
||||
// 'Language' = 'en-US'
|
||||
);
|
||||
$bUseTimeout = true; // 10 seconds
|
||||
$ssoHash = \RainLoop\Api::CreateUserSsoHash($sEmail, $sPassword, $aAdditionalOptions, $bUseTimeout);
|
||||
|
||||
// redirect to webmail sso url
|
||||
\header('Location: https://yourdomain.com/snappymail/?sso&hash='.$ssoHash);
|
||||
|
||||
// Destroy the SSO hash
|
||||
//\RainLoop\Api::ClearUserSsoHash($ssoHash);
|
Loading…
Reference in a new issue