Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Event not being triggered when a new account is created through OAuth #2421

Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Fire event triggers when a account is created
  • Loading branch information
PineappleIOnic committed Nov 16, 2021
commit c868f8abcbdb629c1db171a3ec64b452e34cc727
28 changes: 28 additions & 0 deletions app/controllers/api/account.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Appwrite\Database\Validator\UID;
use Appwrite\Database\Validator\Authorization;
use Appwrite\Detector\Detector;
use Appwrite\Event\Event;
use Appwrite\Template\Template;
use Appwrite\OpenSSL\OpenSSL;
use Appwrite\URL\URL as URLParser;
Expand Down Expand Up @@ -524,7 +525,34 @@
'registration' => \time(),
'reset' => false,
'name' => $name,
'prefs' => [],
], ['email' => $email]);

$createUserEvent = clone $audits;

$createUserEvent
->setParam('eventData', $response->output($user, Response::MODEL_USER))
PineappleIOnic marked this conversation as resolved.
Show resolved Hide resolved
->setParam('event', 'account.create')
->setParam('userId', $user->getId())
->setParam('resource', 'users/'.$user->getId())
->setParam('data', ['provider' => $provider])
->trigger();

$functionsEvent = clone $events;

$functionsEvent
->setQueue('v1-functions')
->setClass('FunctionsV1')
->setParam('eventData', $response->output($user, Response::MODEL_USER))
->trigger();

$webhookEvent = clone $events;

$webhookEvent
->setQueue('v1-webhooks')
->setClass('WebhooksV1')
->setParam('eventData', $response->output($user, Response::MODEL_USER))
->trigger();
} catch (Duplicate $th) {
throw new Exception('Account already exists', 409);
}
Expand Down