- // process login request
-
- $r = q("SELECT * FROM `user`
- WHERE ( `email` = '%s' OR `nickname` = '%s' ) AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
- dbesc(trim($_POST['openid_url'])),
- dbesc(trim($_POST['openid_url'])),
- dbesc($encrypted));
- if(($r === false) || (! count($r))) {
- notice( t('Login failed.') . EOL );
- goaway($a->get_baseurl());
- }
+
+ $addon_auth = array(
+ 'name' => trim($_POST['openid_url']),
+ 'password' => trim($_POST['password']),
+ 'authenticated' => 0
+ );
+
+ /**
+ *
+ * A plugin indicates successful login by setting 'authenticated' to non-zero value
+ * Plugins should never set 'authenticated' except to indicate success - as hooks may be chained
+ * and later plugins should not interfere with an earlier one that succeeded.
+ *
+ */
+
+ call_hooks('authenticate', $addon_auth);
+
+ if(! $addon_auth['authenticated']) {
+ // process login request
+
+ $r = q("SELECT * FROM `user` WHERE ( `email` = '%s' OR `nickname` = '%s' )
+ AND `password` = '%s' AND `blocked` = 0 AND `verified` = 1 LIMIT 1",
+ dbesc(trim($_POST['openid_url'])),
+ dbesc(trim($_POST['openid_url'])),
+ dbesc($encrypted)
+ );
+ if(($r === false) || (! count($r))) {
+ notice( t('Login failed.') . EOL );
+ goaway($a->get_baseurl());
+ }
+ }
+