Get current user from outside

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Get current user from outside

Stefan Herzog

Hi all!

I'm wondering if / how I can get the logged in user from another subdomain?

  • oC is running on 'sub.myDomain.tld'
  • My script is running on 'another.sub.myDomain.tld'

I tried

chdir('../path/to/oC/');    // it didn't work to require_once() the following files directly due to an autoloader exception so I just changed the current dir
require_once 'lib/base.php';
require_once 'lib/public/user.php';

if( \OCP\User::isLoggedIn())
{
    $user->username = \OC::$server->getUserSession();
}
else
{
    $user->username = 'NO_USER';
}

$user->username = \OC::$server->getUserSession()->getUser()->getUID() ;

var_dump($user->username);  // string(7) "NO_USER"

I also added the used subdomain as trusted domain in /config/config.php. I guess I can't just include /lib/base.php, can I? It works if I try this with a file within my oC directory.

 

Many thanks in advance!

Stefan


_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: Get current user from outside

Stefan Herzog
Reality no one? Isn't it possible to include the "oC framework" of the current installation into an external script?

Regards
Stefan


Mit freundlichen Grüßen / Yours sincerely 

Stefan Herzog

Am 25.05.2016 um 08:43 schrieb [hidden email]:

Hi all!

I'm wondering if / how I can get the logged in user from another subdomain?

  • oC is running on 'sub.myDomain.tld'
  • My script is running on 'another.sub.myDomain.tld'

I tried

chdir('../path/to/oC/');    // it didn't work to require_once() the following files directly due to an autoloader exception so I just changed the current dir
require_once 'lib/base.php';
require_once 'lib/public/user.php';

if( \OCP\User::isLoggedIn())
{
    $user->username = \OC::$server->getUserSession();
}
else
{
    $user->username = 'NO_USER';
}

$user->username = \OC::$server->getUserSession()->getUser()->getUID() ;

var_dump($user->username);  // string(7) "NO_USER"

I also added the used subdomain as trusted domain in /config/config.php. I guess I can't just include /lib/base.php, can I? It works if I try this with a file within my oC directory.

 

Many thanks in advance!

Stefan

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: Get current user from outside

Thomas Müller
Hi,

the current user is stored in the session and the session is tight to the domain.

What you are trying to do is not possible from my understanding.

Maybe you can explain what you are looking for to implement.

Regards,

Tom

Am 30. Mai 2016 11:03:36 MESZ, schrieb Stefan Herzog <[hidden email]>:
Reality no one? Isn't it possible to include the "oC framework" of the current installation into an external script?

Regards
Stefan


Mit freundlichen Grüßen / Yours sincerely 

Stefan Herzog

Am 25.05.2016 um 08:43 schrieb [hidden email]:

Hi all!

I'm wondering if / how I can get the logged in user from another subdomain?

  • oC is running on 'sub.myDomain.tld'
  • My script is running on 'another.sub.myDomain.tld'

I tried

chdir('../path/to/oC/');    // it didn't work to require_once() the following files directly due to an autoloader exception so I just changed the current dir
require_once 'lib/base.php';
require_once 'lib/public/user.php';

if( \OCP\User::isLoggedIn())
{
    $user->username = \OC::$server->getUserSession();
}
else
{
    $user->username = 'NO_USER';
}

$user->username = \OC::$server->getUserSession()->getUser()->getUID() ;

var_dump($user->username);  // string(7) "NO_USER"

I also added the used subdomain as trusted domain in /config/config.php. I guess I can't just include /lib/base.php, can I? It works if I try this with a file within my oC directory.

 

Many thanks in advance!

Stefan

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel



Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel

--
Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet.
_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel
Reply | Threaded
Open this post in threaded view
|

Re: Get current user from outside

George Langham
In reply to this post by Stefan Herzog
yes.

On Wed, May 25, 2016 at 7:43 AM, <[hidden email]> wrote:

Hi all!

I'm wondering if / how I can get the logged in user from another subdomain?

  • oC is running on 'sub.myDomain.tld'
  • My script is running on 'another.sub.myDomain.tld'

I tried

chdir('../path/to/oC/');    // it didn't work to require_once() the following files directly due to an autoloader exception so I just changed the current dir
require_once 'lib/base.php';
require_once 'lib/public/user.php';

if( \OCP\User::isLoggedIn())
{
    $user->username = \OC::$server->getUserSession();
}
else
{
    $user->username = 'NO_USER';
}

$user->username = \OC::$server->getUserSession()->getUser()->getUID() ;

var_dump($user->username);  // string(7) "NO_USER"

I also added the used subdomain as trusted domain in /config/config.php. I guess I can't just include /lib/base.php, can I? It works if I try this with a file within my oC directory.

 

Many thanks in advance!

Stefan


_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel




--
Regards,
George William Langham

_______________________________________________
Devel mailing list
[hidden email]
http://mailman.owncloud.org/mailman/listinfo/devel