Skip to content

Commit

Permalink
ionic: added twitter auth
Browse files Browse the repository at this point in the history
  • Loading branch information
sahat committed Jun 17, 2015
1 parent 8119df4 commit 4674aaa
Show file tree
Hide file tree
Showing 2 changed files with 86 additions and 81 deletions.
164 changes: 83 additions & 81 deletions examples/ionic/www/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,102 +6,104 @@
// 'starter.controllers' is found in controllers.js
angular.module('starter', ['ionic', 'satellizer', 'starter.controllers'])

.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if(window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if(window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})
.run(function($ionicPlatform) {
$ionicPlatform.ready(function() {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
})

.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider

.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})
.state('app', {
url: "/app",
abstract: true,
templateUrl: "templates/menu.html",
controller: 'AppCtrl'
})

.state('app.search', {
url: "/search",
views: {
'menuContent' :{
templateUrl: "templates/search.html"
.state('app.search', {
url: "/search",
views: {
'menuContent': {
templateUrl: "templates/search.html"
}
}
}
})
})

.state('app.browse', {
url: "/browse",
views: {
'menuContent' :{
templateUrl: "templates/browse.html"
.state('app.browse', {
url: "/browse",
views: {
'menuContent': {
templateUrl: "templates/browse.html"
}
}
}
})
.state('app.playlists', {
url: "/playlists",
views: {
'menuContent' :{
templateUrl: "templates/playlists.html",
controller: 'PlaylistsCtrl'
})
.state('app.playlists', {
url: "/playlists",
views: {
'menuContent': {
templateUrl: "templates/playlists.html",
controller: 'PlaylistsCtrl'
}
}
}
})
})

.state('app.single', {
url: "/playlists/:playlistId",
views: {
'menuContent' :{
templateUrl: "templates/playlist.html",
controller: 'PlaylistCtrl'
.state('app.single', {
url: "/playlists/:playlistId",
views: {
'menuContent': {
templateUrl: "templates/playlist.html",
controller: 'PlaylistCtrl'
}
}
}
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/playlists');
})
});
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/app/playlists');
})

// Configure Satellizer.
.config(function($authProvider) {
.config(function($authProvider) {

// Configuration common for all providers.
var commonConfig = {
// Popup should expand to full screen with no location bar/toolbar.
popupOptions: {
location: 'no',
toolbar: 'no',
width: window.screen.width,
height: window.screen.height
},
};
// Configuration common for all providers.
var commonConfig = {
// Popup should expand to full screen with no location bar/toolbar.
popupOptions: {
location: 'no',
toolbar: 'no',
width: window.screen.width,
height: window.screen.height
}
};

// Change the platform and redirectUri only if we're on mobile
// so that development on browser can still work.
if (ionic.Platform.isIOS() || ionic.Platform.isAndroid()) {
$authProvider.platform = 'mobile';
commonConfig.redirectUri = 'http://localhost/';
}

// Change the platform and redirectUri only if we're on mobile
// so that development on browser can still work.
if (ionic.Platform.isIOS() || ionic.Platform.isAndroid()) {
$authProvider.platform = 'mobile';
commonConfig.redirectUri = 'http://localhost/';
}
$authProvider.facebook(angular.extend({}, commonConfig, {
clientId: '100703896938969',
responseType: 'token'
}));

// Configure Facebook login.
$authProvider.facebook(angular.extend({}, commonConfig, {
clientId: '657854390977827',
url: 'http://satellizer.herokuapp.com/auth/facebook'
}));
$authProvider.twitter(angular.extend({}, commonConfig, {
url: 'http://localhost:3000/auth/twitter'
}));

// Configure Google login.
$authProvider.google(angular.extend({}, commonConfig, {
$authProvider.google(angular.extend({}, commonConfig, {
clientId: '631036554609-v5hm2amv4pvico3asfi97f54sc51ji4o.apps.googleusercontent.com',
url: 'http://satellizer.herokuapp.com/auth/facebook'
}));
})
url: 'http://localhost:3000/auth/google'
}));
})

;
3 changes: 3 additions & 0 deletions examples/ionic/www/templates/playlists.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<button ng-if="!authenticated" ng-click="authenticate('google')" class="button button-block">
Connect with Google
</button>
<button ng-click="authenticate('twitter')" class="button button-block">
Connect with Twitter
</button>
</div>
<div ng-if="authenticated">
<div class="card">
Expand Down

0 comments on commit 4674aaa

Please sign in to comment.