angularjs-authentication

AngularJS: How to hide the template content until user is authenticated?

半世苍凉 提交于 2019-12-22 18:28:14
问题 My app has 2 pages: main.html and login.html . When not authenticated users go to /main they should be redirected to /login . The problem is that main.html is rendered first, and after a second or so, when user authentication fails, login.html is rendered. How could I prevent from main.html to be rendered until authentication succeeds? Here is the relevant code (CoffeeScript): angular.module('myApp', [...]) .config(['$routeProvider', ($routeProvider) -> $routeProvider.when '/login',

AngularJS | handle routing before they load

十年热恋 提交于 2019-12-17 17:29:31
问题 I wish to create a simple authentication check for my routes by external service. I define the access requirements on the route object: $routeProvider .when('/', { templateUrl: 'src/app/views/index.html', controller: 'indexCtrl', authenticated: true }) .when('/login', { templateUrl: 'src/app/views/login.html', controller: 'loginCtrl', anonymous: true }) .otherwise({ redirectTo: '/' }) ; Then, I check if I have permission within the $routeChangeStart event. $rootScope.$on('$routeChangeStart',

AngularJS: How to hide the template content until user is authenticated?

喜夏-厌秋 提交于 2019-12-06 07:34:50
My app has 2 pages: main.html and login.html . When not authenticated users go to /main they should be redirected to /login . The problem is that main.html is rendered first, and after a second or so, when user authentication fails, login.html is rendered. How could I prevent from main.html to be rendered until authentication succeeds? Here is the relevant code (CoffeeScript): angular.module('myApp', [...]) .config(['$routeProvider', ($routeProvider) -> $routeProvider.when '/login', templateUrl: 'html/login.html' controller: LoginController $routeProvider.otherwise templateUrl: 'html/main.html

Redirect after user has logged in

一个人想着一个人 提交于 2019-12-03 07:06:13
问题 I'm pretty new to Angular, and right now I'm just trying to get all my routes set up and working as I'd like. Setup: When a user navigates to certain pages ( /settings for this example) the app should check if there is a user already logged in. If there is continue as usual. Otherwise the user should go to the login page ( /login ). What I'd like: After the user has successfully logged in they should go to the page they were originally trying to get to ( /settings ) My question: Is there an

Redirect after user has logged in

て烟熏妆下的殇ゞ 提交于 2019-12-02 21:50:54
I'm pretty new to Angular, and right now I'm just trying to get all my routes set up and working as I'd like. Setup: When a user navigates to certain pages ( /settings for this example) the app should check if there is a user already logged in. If there is continue as usual. Otherwise the user should go to the login page ( /login ). What I'd like: After the user has successfully logged in they should go to the page they were originally trying to get to ( /settings ) My question: Is there an "Angular way" to remember where the user was trying to go to? Relevant code: app.js .when('/settings', {

AngularJS | handle routing before they load

蹲街弑〆低调 提交于 2019-11-28 03:36:28
I wish to create a simple authentication check for my routes by external service. I define the access requirements on the route object: $routeProvider .when('/', { templateUrl: 'src/app/views/index.html', controller: 'indexCtrl', authenticated: true }) .when('/login', { templateUrl: 'src/app/views/login.html', controller: 'loginCtrl', anonymous: true }) .otherwise({ redirectTo: '/' }) ; Then, I check if I have permission within the $routeChangeStart event. $rootScope.$on('$routeChangeStart', function (event, next) { if(next.authenticated && !$myService.isLoggedin()) $location.path("/login");

Authentication with AngularJS, session management and security issues with REST Api WS

戏子无情 提交于 2019-11-28 02:46:18
I started developing a web-app with angularJS and I'm not sure that everything is right secured (client and server side). Security is based on a single login page, if credentials are checked ok, my server sends back an unique token with custom time-validity. All other REST api are accessible through this token. The application (client) browse to my entry-point ex: https://www.example.com/home.html user insert credentials and receive back a unique token. This unique token is stored in the server database with AES or other secure techniques, it is not stored in clear format. From now on, my

Authentication with AngularJS, session management and security issues with REST Api WS

谁说胖子不能爱 提交于 2019-11-27 04:58:07
问题 I started developing a web-app with angularJS and I'm not sure that everything is right secured (client and server side). Security is based on a single login page, if credentials are checked ok, my server sends back an unique token with custom time-validity. All other REST api are accessible through this token. The application (client) browse to my entry-point ex: https://www.example.com/home.html user insert credentials and receive back a unique token. This unique token is stored in the

AngularJS- Login and Authentication in each route and controller

夙愿已清 提交于 2019-11-26 00:29:52
问题 I have an AngularJS application created by using yeoman, grunt and bower. I have a login page that has a controller that checks for authentication. If the credentials are correct I reroute to home page. app.js \'use strict\'; //Define Routing for app angular.module(\'myApp\', []).config([\'$routeProvider\', \'$locationProvider\', function($routeProvider,$locationProvider) { $routeProvider .when(\'/login\', { templateUrl: \'login.html\', controller: \'LoginController\' }) .when(\'/register\',