This article describes the various endpoints related to Social Login User Exists API. This API is used to check if a user is a Shopsocially Social Login user based on the email address of the user.


The API Call


ssmi_does_user_exist(email)

Description: This API is used to check if a user is a Shopsocially social login user based on the email address of the user. 



Request Parameter: email

Description: This is the email address of the user.


Call Back Functions

 

ssmi_user_exist_success(response)


This is the success callback method of the API call. The response object is passed as argument. 

The fields of the response object are as follows:


Name

Description

exists

true, if the user exists 

false, if the user doesn't exist

network_type

The type of social network used for login. 

Eg: 'facebook', 'google'

 

ssmi_user_exist_failure(response)


This is the failure callback method of the API call. The response objects is passed as argument. 

The fields of the response object are:


Name

Description

error

Set to true when there is a failure in checking if user exists

reason

The reason for failure.



Example


When a user acquired by Shopsocially social login app attempts to login using email and password, if there are no records of user password in database or if there the password field is blank for the email id, we can use the API to check if the user is a social login user.


Below is the sample code snippet. The snippet contains placeholder code for login handling.


// Upon Login Failure make a call as shown below

// 'ssuser@gmail.com' is the example email id used

ss_mi.ssmi_does_user_exist('ssuser@gmail.com')

//ssmi_user_exist_success(response) will be called by the API.

function window.ssmi_user_exist_success(response){

 if(response.exists == true){

 network_type = response.network_type;

 /*Handle code to alert user saying that account already exists

 and network_type containes 'google'

                                */

 }

 else{

 /*Handle code to alert user that he is a new user and need to

 signup or login using social network*/

 }

}

// Also handle the failure response

function window.ssmi_user_exist_failure(response){

 if(response.error == true){

 /* Some error occurred white retrieving information

 Code to handle error case*/

 }

}


Google Chrome Console log output of response object when user doesn't exists and user exists.


Scenario 1: New user with email address ‘ponusocial@gmail.com’ attempts email login.

  • User data is not available in the  merchant’s database 
  • User data is not available in ShopSocially database


Scenario 2: Social Login user with email address ‘sun2fb@gmail.com’ attempts email login.

  • User data is not available in the merchant’s database 
  • User data is available in ShopSocially database