OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)

This commit is contained in:
wangruiguo
2026-09-03 18:49:20 +08:00
commit d647428529
3501 changed files with 1988906 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
<?php
namespace Leantime\Domain\Auth\Guards;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\UserProvider;
use Leantime\Core\Http\ApiRequest;
use Leantime\Core\Http\IncomingRequest;
use Leantime\Domain\Api\Services\Api;
use Leantime\Domain\Auth\Models\AuthenticatableUser;
class ApiGuard implements Guard
{
protected $user;
private string $apiKey = '';
public function __construct(
protected UserProvider $provider,
protected Api $apiService,
protected IncomingRequest $request)
{
if ($this->request instanceof ApiRequest && $this->request->isApiRequest()) {
$this->apiKey = $this->request->getAPIKey();
}
}
public function check()
{
if (empty($this->apiKey)) {
return false;
}
$apiUser = $this->apiService->getAPIKeyUser($this->apiKey);
if (! $apiUser) {
return false;
}
return true;
}
public function guest()
{
return ! $this->check();
}
public function user()
{
if ($this->user !== null) {
return $this->user;
}
if (empty($this->apiKey)) {
return $this->user;
}
$apiUser = $this->apiService->getAPIKeyUser($this->apiKey);
if (! $apiUser) {
$this->user = null;
return $this->user;
}
$this->user = new AuthenticatableUser((array) $apiUser);
return $this->user;
}
public function id()
{
return $this->user()?->getAuthIdentifier();
}
public function validate(array $credentials = [])
{
if (empty($this->apiKey)) {
return false;
}
$apiUser = $this->apiService->getAPIKeyUser($this->apiKey);
if (! $apiUser) {
return false;
}
return true;
}
public function hasUser()
{
return $this->user ? true : false;
}
public function setUser(Authenticatable $user)
{
$this->user = $user;
return $this;
}
}

View File

@@ -0,0 +1,71 @@
<?php
namespace Leantime\Domain\Auth\Guards;
use Illuminate\Contracts\Auth\Authenticatable;
use Illuminate\Contracts\Auth\Guard;
use Illuminate\Contracts\Auth\UserProvider;
use Leantime\Domain\Auth\Services\Auth as AuthService;
class WebGuard implements Guard
{
protected $provider;
protected $user;
protected AuthService $authService;
public function __construct(UserProvider $provider, AuthService $authService)
{
$this->provider = $provider;
$this->authService = $authService;
}
public function check()
{
return $this->authService->loggedIn();
}
public function guest()
{
return ! $this->check();
}
public function user()
{
if ($this->user !== null) {
return $this->user;
}
if ($this->authService->loggedIn()) {
$this->user = $this->provider->retrieveById($this->authService::getUserId());
}
return $this->user;
}
public function hasUser()
{
return $this->user ? true : false;
}
public function id()
{
return $this->user()?->getAuthIdentifier();
}
public function validate(array $credentials = [])
{
return $this->authService->login(
$credentials['username'],
$credentials['password']
);
}
public function setUser(Authenticatable $user)
{
$this->user = $user;
return $this;
}
}