c# - Routing between two projects in angularjs -


i looking @ article how angular app routing between 2 projects.

i have 2 projects called presentation.web , security.web.

in security.web have controllers authentication service. once user has been authenticated page needs redirected home page in presentation.web.

how achieve using single app? or how can route between 2 apps? i'm using visual studio 2013 develop project (developing angularjs app c#)

i have controller registration , sign in under security.web(highlighted in screenshot) project

have controller registration , sign in

and have home controller , todocontroller under presentation.web project(highlighted in screenshot) when user signedin page has redirected todomanager.

signincontroller:

        .success(function (data, status, headers, config) {             $http.defaults.headers.common.authorization = "bearer " + data.access_token;             $http.defaults.headers.common.refreshtoken = data.refresh_token;              $cookiestore.put('_token', data.access_token);             window.location = '#/todomanager';         }) 

home controller

now want app have routing pages in normal way using want route modules between these 2 projects. possible route module in below?

//================================================ // routes //================================================ $routeprovider.when('/home', {     templateurl: 'app/home',     controller: 'homectrl' }); $routeprovider.when('/register', {     templateurl: 'app/register',     controller: 'registerctrl' }); $routeprovider.when('/signin/:message?', {     templateurl: 'app/signin',     controller: 'signinctrl' }); $routeprovider.when('/todomanager', {     templateurl: 'app/todomanager',     controller: 'todomanagerctrl' });`app.run(['$http', '$cookies', '$cookiestore', function ($http, $cookies, $cookiestore) { //if token exists in cookie, load after app loaded, application can maintain authenticated state. $http.defaults.headers.common.authorization = 'bearer ' + $cookiestore.get('_token'); $http.defaults.headers.common.refreshtoken = $cookiestore.get('_refreshtoken');}]);` 

here im getting token in presentation.web

app.run(['$rootscope', '$http', '$cookies', '$cookiestore', function ($rootscope, $http, $cookies, $cookiestore) {  $rootscope.logout = function () {      $http.post('/api/account/logout')         .success(function (data, status, headers, config) {             $http.defaults.headers.common.authorization = null;             $http.defaults.headers.common.refreshtoken = null;             $cookiestore.remove('_token');             $cookiestore.remove('_refreshtoken');             $rootscope.username = '';             $rootscope.loggedin = false;             window.location = '#/signin';         });  }  $rootscope.$on('$locationchangesuccess', function (event) {     if ($http.defaults.headers.common.refreshtoken != null) {         var params = "grant_type=refresh_token&refresh_token=" + $http.defaults.headers.common.refreshtoken;         $http({             url: '/token',             method: "post",             headers: { 'content-type': 'application/x-www-form-urlencoded' },             data: params         })         .success(function (data, status, headers, config) {             $http.defaults.headers.common.authorization = "bearer " + data.access_token;             $http.defaults.headers.common.refreshtoken = data.refresh_token;              $cookiestore.put('_token', data.access_token);             $cookiestore.put('_refreshtoken', data.refresh_token);              $http.get('/api/ws_account/getcurrentusername')                 .success(function (data, status, headers, config) {                     if (data != "null") {                         $rootscope.username = data.replace(/["']{1}/gi, "");//remove quotes username before pushing out.                         $rootscope.loggedin = true;                     }                     else                         $rootscope.loggedin = false;                 });           })         .error(function (data, status, headers, config) {             $rootscope.loggedin = false;         });     } }); 

}]);

or can routing?


Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -