ElkArte Community

Extending Elk => Addons => Topic started by: ahrasis on March 24, 2017, 08:36:41 am

Title: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 24, 2017, 08:36:41 am
OASL - ONE ALL SOCIAL LOGIN is an addon for multiple social login which can be registered and set at https://app.oneall.com/signin/ and the relevant social media.[1]It is free up to  2,500 unique users per year.[2].

This is a non-stable-alpha-package but do not use it in an active forum of yours, unless you really know what  you are doing. It is attached below and will be updated only if I know how, so do contribute, at least by reporting errors.[3].

(Link-4654) (Link-4652) (Link-4650) (Link-4656) (Link-4658)
You can upgrade to premium service for more but I am not promoting this.
I hope this can be a start for coding multiple social login / registration to ElkArte forum whether using Hybridauth as suggested by @emanuele or something similar/better.
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: emanuele on March 24, 2017, 11:14:07 am
I suggest many things, not that I can keep up with the expectations! xD
Anyway good job! :D
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 26, 2017, 07:16:53 am
I might just drop this effort since @Spuds already come out with the fully free version just now using HybridAuth in this post (http://www.elkarte.net/community/index.php?topic=4370.0). However, I decided that I will continue with it.

Tested the latest version and ended up this error.
QuoteThe database value you're trying to insert does not exist: member_ip
Function: registerMember
https://elkarte.sch.my/index.php?action=oasl_callback;oasl_source=login
/var/www/clients/client2/web1/web/sources/subs/Members.subs.php
Line: 778

Seems like it is asking for member ip but it is not supplied by the addon. Will try to resolve this if I got some idea on how to resolve it.
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: Spuds on March 26, 2017, 09:02:49 am
Yes please continue ! 

This version has several features which I have not done with HybridAuth and it will be good to know what features / control folks want use.  Plus this one has some learning history with it since its been around, some of that can be useful.
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 27, 2017, 03:14:44 am
I learned some code from your Social Login @Spuds and from that I added ip and ip2 in the new version of this addon.

Adding user via facebook will get error 500 but after a refresh, the user is logged in.

I think the following is the fix in the sdk file but it doesn't import the avatar if I am using it. If I am not using it, the addon will import the avatar, but with the above error 500:
						require_once(SUBSDIR . '/ManageAttachments.subs.php');
removeAttachments(array('id_member' => $id_member));

Will keep trying...
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: emanuele on March 27, 2017, 03:42:11 pm
1.0 or 1.1?
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 27, 2017, 07:32:40 pm
Tested this on 1.0.
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: emanuele on March 29, 2017, 05:08:50 am
Can you have a look what are the surroundings of line 778 in your Members.subs.php?
And post the relevant query? (I think you are using a testing one and may be slightly different from the one in the repo right now.)
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 30, 2017, 05:13:27 am
Yes. After modification, here is the the line from 754 to 800:
Quote   // Call an optional function to validate the users' input.
   call_integration_hook('integrate_register', array(&$regOptions, &$theme_vars, &$knownInts, &$knownFloats));

   $column_names = array();
   $values = array();
   foreach ($regOptions['register_vars'] as $var => $val)
   {
      $type = 'string';
      if (in_array($var, $knownInts))
         $type = 'int';
      elseif (in_array($var, $knownFloats))
         $type = 'float';
      elseif ($var == 'birthdate')
         $type = 'date';

      $column_names[$var] = $type;
      $values[$var] = $val;
   }

   // Register them into the database.
   $db->insert('',
      '{db_prefix}members',
      $column_names,
      $values,
      array('id_member') <--- line 778
   );
   $memberID = $db->insert_id('{db_prefix}members', 'id_member');

   // Update the number of members and latest member's info - and pass the name, but remove the 's.
   if ($regOptions['register_vars']['is_activated'] == 1)
      updateMemberStats($memberID, $regOptions['register_vars']['real_name']);
   else
      updateMemberStats();

   // Theme variables too?
   if (!empty($theme_vars))
   {
      $inserts = array();
      foreach ($theme_vars as $var => $val)
         $inserts[] = array($memberID, $var, $val);
      $db->insert('insert',
         '{db_prefix}themes',
         array('id_member' => 'int', 'variable' => 'string-255', 'value' => 'string-65534'),
         $inserts,
         array('id_member', 'variable')
      );
   }
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: emanuele on March 30, 2017, 05:53:00 pm
The 500 error I think it's just a missing:
Code: [Select]
require_once(SUBSDIR . '/ManageAttachments.subs.php');
in oneall_social_upload_user_avatar.
Worth a try.

On the db error, at the moment I'm a little lost.
I guess the error log doesn't give anything more than that.
The problem is with the preg_replace_callback of the insert, but the insert should not be able to create such an error I think...
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 30, 2017, 09:59:27 pm
Mentioned that in reply#4 as a solution for error 500, but as mentioned there as well, the avatar doesn't shows if I am using that option. I haven't look into this for few days but I will compare some more with @Spuds Social Login version and see what EA related code OASL might be missing or something later.
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: emanuele on March 31, 2017, 07:15:28 am
In reply #4 you added a:
Code: [Select]
removeAttachments(array('id_member' => $id_member));
to the require_once, so it's kind of normal that the avatar wouldn't show up. :P
I'm saying you miss just the require_once. ;)
Title: Re: [ADDON] OASL - ONE ALL SOCIAL LOGIN
Post by: ahrasis on March 31, 2017, 09:52:21 am
Code: [Select]
require_once(SUBSDIR . '/ManageAttachments.subs.php');
removeAttachments(array('id_member' => $id_member));
This second line of the code is already in the function twice and the require once is what I added, not the other way around. It failed to show the avatar.

I also tried this way and it also failed to show the avatar:
Code: [Select]
	// Manage Attachments.
require_once(CONTROLLERDIR . '/Attachment.controller.php');
require_once(SUBSDIR . '/ManageAttachments.subs.php');

All of the above mods are made inside of the oneall_social_upload_user_avatar function.

There is a link created for the avatar though, but it is broken.

So far I don't know what else to try.