angularjs - Login Authentication with Devise (rails) & Angular -
i have mobile application can create issues, , view list of issues others have created around location.
the mobile app is talking rails server , creating issues, , have followed guide covering authentication rails & devise.
in controllers/app.js
file, have local variable stored isloggedin
set false default. when application loaded, check see whether variable true , if so, send user app.issues
. otherwise, user sent app.auth.login
.
$scope.$storage = $localstorage.$default({ isloggedin: false }); $scope.$watch('$storage.isloggedin', function() { if ($scope.$storage.isloggedin){ console.log('is logged in'); $state.go('app.issues'); } else { console.log('isnt logged in'); $state.go('app.auth.login'); } });
here root app.js
file in js
folder.
angular.module('orangecone', ['ionic', 'orangecone.controllers', 'orangecone.services', 'ngcordova', 'ngstorage', 'ngresource']) .run(function($ionicplatform) { $ionicplatform.ready(function() { // hide accessory bar default (remove show accessory bar above keyboard // form inputs) if (window.cordova && window.cordova.plugins && window.cordova.plugins.keyboard) { cordova.plugins.keyboard.hidekeyboardaccessorybar(true); cordova.plugins.keyboard.disablescroll(true); } if (window.statusbar) { // org.apache.cordova.statusbar required statusbar.styledefault(); } }); }) .value('constants', { serverurl: 'http://localhost:3000/' }) .config(function($stateprovider, $urlrouterprovider, $httpprovider) { $httpprovider.defaults.withcredentials = true; $stateprovider // setup abstract state tabs directive .state('app', { url: '/app', abstract: true, templateurl: 'templates/tabs.html' }) .state('app.issues', { url: '/issues', views: { 'app-issues': { templateurl: 'templates/issues.html', controller: 'issuesctrl' } } }) .state('app.issue', { url: '/issues/:issueid', views: { 'app-issues': { templateurl: 'templates/issue.html', controller: 'issuectrl' } } }) .state('app.auth', { url: '/auth', abstract: true, templateurl: 'templates/auth/tabs.html' }) .state('app.auth.login', { url: '/login', views: { 'login': { templateurl: 'templates/auth/login.html', controller: 'authctrl' } } }) .state('app.auth.register', { url: '/register', views: { 'register': { templateurl: 'templates/auth/register.html', controller: 'authctrl' } } }) // if none of above states matched, use fallback $urlrouterprovider.otherwise('/app/auth/login'); });
i have waning feeling overlooking rather trivial. application console.logs logged in
though rails server wiped , there no users in system @ all. application should redirecting user app/auth/login
never does. whenever type url browser redirects me app/issues
page.
any thoughts or opinions appreciated.
Comments
Post a Comment