This repository has been archived on 2018-07-08. You can view files and clone it, but cannot push or open issues or pull requests.
auth/index.php

30 lines
634 B
PHP

<?php
if (empty($_POST['user']) || empty($_POST['pw']))
die('0');
function authenticate($user, $pass){
// Check with IMAP server
// We try to open a connection with the server
$connection = @imap_open('{mail.tilde.team:143/tls}/INBOX', $user, $pass);
// Check if we have a proper resource
if (!is_resource($connection)) {
return false;
}
// Close the connection if success
imap_close($connection);
return true;
}
$auth = authenticate($_POST['user'], $_POST['pw']);
echo json_encode([
"authenticated" => $auth,
"sudoer" => $auth && in_array($_POST["user"], posix_getgrnam("sudo")["members"])
]);