Social authentication made easy

Little question to introduce

80%

of users dislike traditional registration forms

http://goo.gl/y1x78a

73%

prefer to log in using their social accounts

2MB

500KB

2MB

2MB

500KB

~1KB

~1KB

Configuration first

"loopback-component-satellizer": {
  "facebook": {
    "model": "Account",
    "credentials": {
      "public": "this_is_a_client_id",
      "private": "this_is_a_private_key"
    },
    "version": "v2.3",
    "fields": ["email"],
    "uri": "/facebook",
    "mapping": {
      "id": "facebook",
      "email": "email",
      "first_name": "firstName",
      "last_name": "lastName",
      "gender": "gender"
    }
  }
}

Server side

angular.module 'my-module', [
  'satellizer'
]
    
.config ($authProvider) ->
    
  $authProvider.authHeader = 'x-access-token'
  $authProvider.authToken = null

  host = window.location.origin or
  window.location.protocol + '//' + window.location.host

  $authProvider.facebook
    clientId: '@@FACEBOOK_CLIENT_ID'
    url: host + '/api/accounts/facebook' 
    scope: ['email']
    scopeDelimiter: ','
    redirectUri: host + '/'
    requiredUrlParams: ['display']
angular.module 'my-ionic-module', [
  'satellizer'
]

.config ($authProvider) ->
  commonConfig =
    popupOptions:
      location: 'no'
      toolbar: 'no'            
      width: window.screen.width      
      height: window.screen.height    
  
  $authProvider.authHeader = 'satellizer'
  $authProvider.authToken = null  
  $authProvider.baseUrl = null 
      
  if ionic?.Platform?.isIOS() or ionic?.Platform?.isAndroid() 
    $authProvider.cordova = true    
    commonConfig.redirectUri = 'http://localhost/'
    
  host = '@@SERVER_URL'        
    
  $authProvider.facebook angular.extend {}, commonConfig,
    clientId: '@@FACEBOOK_CLIENT_ID'
    url: host + '/api/accounts/facebook' 
    scope: ['email']           
    scopeDelimiter: ','        
    requiredUrlParams: ['display']

Loopback-Satellizer

By Jérémie Drouet

Loopback-Satellizer

  • 1,944