Add user login to admin interface
This commit is contained in:
parent
dbe494751a
commit
82bfc15057
15 changed files with 256 additions and 79 deletions
34
internal/wisski/ingredient/php/extras/users.go
Normal file
34
internal/wisski/ingredient/php/extras/users.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package extras
|
||||
|
||||
import (
|
||||
_ "embed"
|
||||
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/phpx"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/status"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient"
|
||||
"github.com/FAU-CDI/wisski-distillery/internal/wisski/ingredient/php"
|
||||
)
|
||||
|
||||
type Users struct {
|
||||
ingredient.Base
|
||||
|
||||
PHP *php.PHP
|
||||
}
|
||||
|
||||
//go:embed users.php
|
||||
var usersPHP string
|
||||
|
||||
// All returns all known usernames
|
||||
func (u *Users) All(server *phpx.Server) (users []string, err error) {
|
||||
err = u.PHP.ExecScript(server, &users, usersPHP, "list_users")
|
||||
return
|
||||
}
|
||||
|
||||
func (u *Users) Fetch(flags ingredient.FetcherFlags, info *status.WissKI) (err error) {
|
||||
if flags.Quick {
|
||||
return
|
||||
}
|
||||
|
||||
info.Users, _ = u.All(flags.Server)
|
||||
return
|
||||
}
|
||||
16
internal/wisski/ingredient/php/extras/users.php
Normal file
16
internal/wisski/ingredient/php/extras/users.php
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
<?php
|
||||
|
||||
use Drupal\user\Entity\User;
|
||||
|
||||
/** lists all the users */
|
||||
function list_users() {
|
||||
|
||||
$usernames = [];
|
||||
$users = User::loadMultiple(NULL);
|
||||
foreach($users as $user){
|
||||
$name = $user->get('name')->getString();
|
||||
if(empty($name)) continue;
|
||||
$usernames[] = $name;
|
||||
}
|
||||
return $usernames;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue