Skip to content

Commit 232d896

Browse files
committed
feat: fire action hook on successful login
1 parent d0f35ef commit 232d896

2 files changed

Lines changed: 12 additions & 1 deletion

File tree

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,13 @@ If you'd like to help this plugin play nice with other providers, please
1616

1717
## Screenshots
1818

19-
![OAuth2 Strategy Editing](./screenshots/configure.png)
19+
![OAuth2 Strategy Editing](./screenshots/configure.png)
20+
21+
## For Developers
22+
23+
Other plugins can interact with this plugin, as it fires the following hooks:
24+
25+
1. On successful login — `action:oauth2.login` — passes in `(name, user, profile)`
26+
* `name` is the strategy name.
27+
* `user` is the local NodeBB user (probably just the `uid`).
28+
* `profile` is the remote profile as retrieved by this plugin.

library.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,8 @@ OAuth.loadStrategies = async (strategies) => {
9393
winston.verbose(`[plugin/sso-oauth2-multiple] Successful login to uid ${user.uid} via ${name} (remote id ${id})`);
9494
authenticationController.onSuccessfulLogin(req, user.uid);
9595
done(null, user);
96+
97+
plugins.hooks.fire('action:oauth2.login', { name, user, profile });
9698
}));
9799

98100
configs.forEach((strategy, idx) => {

0 commit comments

Comments
 (0)