Hello all, I need some help with firefox os and ng-cordova-oauth.
I want to login using a github account but I have an strange behaviour in my app, after I’ve logged in on github, the app redirects to my index but it seems that the app embeds the index instead of redirecting to it. See the image below.
This is the code of my app.js:
angular.module('githubIssuesApp', ['ionic', 'ngCordova'])
.config(function($stateProvider, $urlRouterProvider){
$stateProvider
.state('home', {
url: '/',
templateUrl: 'templates/home.html',
controller: 'homeCtrl',
data: {
authenticate: true
}
})
.state('signin', {
url: '/signin',
templateUrl: 'templates/signin.html',
controller: 'signInCtrl',
data: {
authenticate: false
}
});
$urlRouterProvider.otherwise('/signin');
})
.run(function($ionicPlatform, $rootScope, $state, userService) {
$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) {
StatusBar.styleDefault();
}
});
// UI Router Authentication Check
$rootScope.$on('$stateChangeStart',
function(event, toState, toParams, fromState, fromParams){
console.log('state change start');
if(toState.data.authenticate && !userService.isLoggedIn()){
event.preventDefault();
$state.transitionTo('signin');
}
}
);
})
/**
* sign in controller
*/
.controller('signInCtrl', ['$scope', 'userService', function($scope, userService){
$scope.signIn = userService.login;
}])
**
* User service
*/
.factory('userService', ['$rootScope', '$state', '$cordovaOauth',
function($rootScope, $state, $cordovaOauth) {
var provider = 'github';
var service = {
isLoggedIn: function() {
return $rootScope.userStatus;
},
login: function() {
$cordovaOauth.github('27879518b3200cb586da', '3451fe872df74723655133d8e2c20c68417a4079', ['email'])
.then(function(data){
console.log(data);
$rootScope.user = data;
$rootScope.$apply($rootScope.user);
$rootScope.userStatus = true;
$state.go('home');
}, function(err){
alert(err);
});
},
logout: function() {
console.log("logut");
}
};
return service;
}
]);
and this is the manifest.webapp:
{
"launch_path": "/index.html",
"installs_allowed_from": [
"*"
],
"version": "0.0.1",
"name": "github-issues",
"description": "...",
"developer": {
"name": "Mozilla El Salvador",
"url": "http://carloscarcamo.me"
},
"icons": {
"60": "/icon/icon-60.png",
"128": "/icon/icon-128.png"
},
"redirects":[{
"from":"http://localhost/callback",
"to":"/index.html"
}]
}
Note: the redirects at the end of the app manifest is necessary because firefox simulator gives 404 error with http://localhost, so I redirect from http://localhost/callback to my index.
Any thoughts about what i’m doing wrong?