Search Posts

Category: authentication

AngularJS Login using HTTP Get with a JSON file

I am trying to create a user logon page where the user’s input is compared against a JSON file of usernames and passwords (yes, I know client-side authentication is a terrible idea, but this is purely for developing my skills and isn’t a real project. $http.get(‘https://XXXXXXXXXX/user_list.json’) .then(function(response) { $scope.userlist = response.data; angular.forEach($scope.userlist, function(item) {}); }); $scope.JSONLogin = function() { angular.forEach($scope.userlist, function(item) { if ((item.LoginName == $scope.uName) && (item.Password == $scope.pWord)) { window.alert(“Success); // } }); […]

AngularJS token authentication with sliding expiration in state transitions with ui-router version 1.x

In our application we have a requirement that user should be logged in for a certain amount of time which is configurable by system admin, say 10 minutes. We have another requirement that the when user navigates to different parts of the app, this time should be refreshed and set back to that configured amount. Our application is written in AngularJS and we use ui-router for routing, So when user navigates between different states, time […]

Angularjs Uncaught Error: [$injector:unpr] Unknown provider: authInterceptorProvider <- authInterceptor <- $http <- $templateRequest <- $route

how to Angularjs Uncaught Error: [$injector:unpr] Unknown provider: authInterceptorProvider <- authInterceptor <- $http <- $templateRequest <- $route I just inherited a small angularjs project that used DNX SDK 1.0.0-beta5, bower and gulp. So I am in the middle of the process of getting rid of all that stuff. For that I created a new project in VS2015 an addedd all the references needed using nu-get. Except for ui-bootstrap that I downloaded from their git hub […]

Getting response code 401 causes skipping code blocks

I’m writing an ionic v1/express/mongo/node app. When checking if the user is authenticated i have the following piece of code: checkAuthentication: function(token) { console.log(token); return $http.get(“http://validUrl/test”, { headers: { ‘testingAuth’: token } }).then(function(result) { return result.data; }); } and am calling it like this: checkAuthentication(token).then(function(response) { console.log(“testing response: ” + response); // if a valid token is already in storage = response contains “Success”(?), just $state.go to main page, else call the login() function if […]

error 401 authenticate user at login page angularjs

I am creating a simple login form with only ‘username’ and ‘password’ fields. I have this as my auth.js and it keeps showing authentication error. I am new in coding and have copied and pasted from a few of my previous projects to create my own. Please help me see where went wrong and teach me if i’m doing authenticated right. I am connected to MySQL and have one admin account there. All this time […]

Authenticate all Request to REST API with no username/password to get any token

I am selling products, API fetch product from node back-end and show on angular front-end, Back-end is centralized and angular front-end is on multiple domain, I need to authenticate all request made from my angular front-end to node back-end. Users d’t have account. I need to make sure no one else copy the product data via POSTMAN or other services. JWT is not working as request are exposed so token can be copied so authentication […]

Power BI angular1 authentication

I am trying to integrate Power BI into angular 1 application. From my research i came to know i have to follow following process Authenticate User and get access token By using this token get Embed token But i am struck at first step. How to authenticate? i have made an API call to https://login.microsoftonline.com/common/oauth2/token with parameters : grant_type:’password’, client_id: clientId, resource:’https://analysis.windows.net/powerbi/api‘, scope:’openid’, username:username, password:password, client_secret : client_secret i am getting following response : “error”: […]

Django REST framework custom format for all out responses

In my project I use DRF as backend and Angular as frontend. Django==1.10 djangorestframework==3.7.1 I need all responses from DRF to be in the following format. { “status”: “”, // 200,400,…..etc “error”: “”, // True, False “data”: [], // data “message”: “” // Success messages } for this i have written a custom viewset and overridden the functions list, detail, create, update class ResponseModelViewSet(viewsets.ModelViewSet): def list(self, request, *args, **kwargs): queryset = self.filter_queryset(self.get_queryset()) page = self.paginate_queryset(queryset) […]

Methods of saving user info in AngularJS

I want to know about the ways of saving user info. Many seniors have recommended using $cookieStore, or Authentication or etc. But how about using $rootScope? My idea is when user has logged in, saving his/her id and password into $rootScope. (Naming like $rootScope.user_id = ‘stupid’;) Is this dangerous way? I don’t know whether this question is duplicated or not, but I couldn’t find one talking about using $rootScope. . . UPDATE My config is […]

How Authorization Token Works?

I am trying to understand how the Token system works between Web api and Angular JS for the authentication purpose. Please correct me if I am wrong. The token is stored in a database table and add the token manually on our client application to accompany every request we make from the client. Thanks. Source: AngularJS

Next Page »