Question: I'd want to replace the text `Check{{product.name}}` to `Check{{user}}` if a condition is true. 

I spent hours, tried `hidden, display:none, .hide()` etc. but none of them worked..
I also tried to create another `<a>` block for `check{{user}}` and hide the block if the condition is not true, but it does not work as well....

Wondering if someone could please help! Thanks.

There is my code:

**html:**

```
<ion-footer-bar class="bar-positive" ng-if="loggedUser!=user.id" > 
    <a href="link" id="newtest"> check {{product.name}}</a> 
</ion-footer-bar> 

```

**js:**

```
if (user_name !=''){ 
    //change Check{{product.name}}" to "Check{{uesr}}"
}; 

```

Answer: 
**SHORT ANSWER**

1. You have to link the social login user to your standard user table and generate the (JWT) token as you are already doing
2. Social logins always return an ID identifying the user on the social. In an external table, store the social used and the social\_id, together with the user\_id of you main users table

---

**LONG ANSWER**

Let's start from the beginning in order to have a better view of all the issue and clear all the aspect of your doubts.

**Basic user table**  

Usually you have a Users table structured in this way (simplified)

* user\_id
* login (email)
* password
* jwt\_token

When the user login, you are going to update the jwt\_token field and return it to the user in order to consume your APIs.

**Implementing social logins**  

A good approach to add social logins is to create a new social\_logins table structured as follow (simplified)

* social
* social\_id
* user\_id

Once you "social login" a user, you get a list of data from the social network itself. Note that users can disallow the retrieve of the private email address (ex. from Facebook) even if you are explicitly asking for it.

The first thing you have to do is to check if the social returned you the user's email address.

* if an email returned, look for a user with that email address in your users table and create a record in "social\_logins" table creating a relation with the user using the user\_id field
* if the email is blank, you have to create a new user in the user table creating a "fake" email address (with a standard method - not random) and then create your social\_login record

To avoid creating double users (different email addresses), I always prefer to ask the user to confirm his email address: with this simple question you can postpone the previous check and reduce the amount of double users. So, if the social login isn't returning you the email address, you just show an empty field asking the users to fill it with their email address that you will then use to look for a user in the users table. If instead you got it, just show the user the same field filled and ask him to confirm the email address or change it if he prefer to use another address or if he is already registered to your app with another email address.
Some social networks allow to delegate user authentication instead or requiring credentials in your own system. When user logs in, the external platform will provide you an access token that can be used to get some information of the user.

Use this data to register the user into your own system. Attach also the access token provided. Depending on the permissions you have requested, you can use the token to perform additional operation in the social platform.

Then issue a JWT to be used as authentication token in the web/mobile app where user logged on. Note that this JWT must be independent of the access token sent by authentication provider. Include some claims of interest like `sub` or `exp` and sign it with a secret key. For example

```
 {
   "sub": "userid",     //unique user id assigned in your system 
   "name": "User name"  //Name provided by social 
   "iss": "issuer",     //you are the issuer
   "exp": 1300819380,   //Expiration date
   "login":"facebook"   //login method used
  }

```

If you plan to use several authentication systems like Google or Facebook, do not use the email as unique identifier because it could different for the same user. You will need an additional register process to link the accounts that the user has in different networks. For example, letting user set the identifier that is using in the other system or just launch the log in process in Twitter when user is logged by Facebook