diff options
| author | winter | 2024-12-16 20:27:01 +0000 |
|---|---|---|
| committer | winter | 2024-12-16 20:41:33 +0000 |
| commit | 68c7e68b3f90fd980661774fdb2bb2d6140a34d0 (patch) | |
| tree | 7993de39c7c637369bdbfb22e265319b43fcbf33 /Digitigrade/Model/Instance.php | |
| parent | 2f4c1de3509141880df019ef1a6cc65981b3f6ea (diff) | |
implement the other side of auth (hopefully?)
also mostly untested for the same reason as last time
Diffstat (limited to 'Digitigrade/Model/Instance.php')
| -rw-r--r-- | Digitigrade/Model/Instance.php | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Digitigrade/Model/Instance.php b/Digitigrade/Model/Instance.php index 5f33e6d..e4b1ef1 100644 --- a/Digitigrade/Model/Instance.php +++ b/Digitigrade/Model/Instance.php @@ -58,6 +58,20 @@ class Instance extends FetchableModel { return self::fetchFromRemote($uri, $autoSave); } + public static function findByInboundAuthToken(string $token): ?self { + $authRecord = InstanceAuth::findWhere('inbound_token = ?', [$token]); + if ($authRecord == null) + return null; + return self::find($authRecord->instanceId); + } + + public static function findByDialbackSecret(string $secret): ?self { + $authRecord = InstanceAuth::findWhere('secret = ?', [$secret]); + if ($authRecord == null) + return null; + return self::find($authRecord->instanceId); + } + public function beginOutboundAuth() { $authEndpoint = $this->endpoints->auth; if (!isset($authEndpoint)) { |
