aboutsummaryrefslogtreecommitdiff
path: root/engine
diff options
context:
space:
mode:
authorSteve Clay <steve@mrclay.org>2013-10-06 17:07:42 -0700
committerSteve Clay <steve@mrclay.org>2013-10-06 17:07:42 -0700
commit94dbd504b6b3f4245f92cee1a3222445c7c3f41e (patch)
treee3740af54bfed84bc54a094d437eb9b1cc0a9999 /engine
parent3a68d33d8b0ce41c0a94331ba772e64544406fab (diff)
parentceb9829595b62330ec0d6903287c498e6d6ee37c (diff)
downloadelgg-94dbd504b6b3f4245f92cee1a3222445c7c3f41e.tar.gz
elgg-94dbd504b6b3f4245f92cee1a3222445c7c3f41e.tar.bz2
Merge pull request #6106 from jeabakker/6100-webservices-auth-gettoken
fixes #6100 auth_gettoken now works with email address
Diffstat (limited to 'engine')
-rw-r--r--engine/lib/web_services.php13
1 files changed, 12 insertions, 1 deletions
diff --git a/engine/lib/web_services.php b/engine/lib/web_services.php
index b440e3afb..51cad6f39 100644
--- a/engine/lib/web_services.php
+++ b/engine/lib/web_services.php
@@ -1166,6 +1166,17 @@ function list_all_apis() {
* @access private
*/
function auth_gettoken($username, $password) {
+ // check if username is an email address
+ if (is_email_address($username)) {
+ $users = get_user_by_email($username);
+
+ // check if we have a unique user
+ if (is_array($users) && (count($users) == 1)) {
+ $username = $users[0]->username;
+ }
+ }
+
+ // validate username and password
if (true === elgg_authenticate($username, $password)) {
$token = create_user_token($username);
if ($token) {
@@ -1195,7 +1206,7 @@ $ERRORS = array();
*
* @return void
* @access private
- *
+ *
* @throws Exception
*/
function _php_api_error_handler($errno, $errmsg, $filename, $linenum, $vars) {