-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathuser.php
More file actions
39 lines (38 loc) · 1.36 KB
/
Copy pathuser.php
File metadata and controls
39 lines (38 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
session_start();
require "vendor/autoload.php";
use myPHPnotes\Microsoft\Auth;
use myPHPnotes\Microsoft\Handlers\Session;
use myPHPnotes\Microsoft\Models\User;
// Check Session
if (is_null(Session::get("tenant_id"))) {
// if not logged in
// login logic
echo "MS Login Here:";
?>
<br><a href="/login.php">LOGIN</a>
<?php
} else {
$microsoft = new Auth(Session::get("tenant_id"),Session::get("client_id"), Session::get("client_secret"), Session::get("redirect_uri"), Session::get("scopes"));
$user = (new User); // User get pulled only if access token was generated for scope User.Read
var_dump($user->data);
$groups = $user->graph()->createRequest("get", "/me/memberOf")->execute()->getBody()["value"];
$ids = array_column($groups, 'id');
?>
<hr>
<p>Username is <code><?php echo $user->data->getMail(); ?></code></p>
<p id="conn_string">Connection command: <code>ssh <?php echo $user->data->getMail(); ?>@pubnix.engsoc.net</code> <button onclick="myFunction()">Copy</button></p>
<button>Reset Password</button>
<?php
// account doesnt exist
?>
<hr>
<p id="conn_string">Connection command: <code>ssh USERNAME@pubnix.engsoc.net</code></p>
<button>Create Account</button>
<?php
// account banned
?>
<hr>
<h1 style="text-align: center;color: darkred">Account banned</h1>
<?php
}