Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- angular.module('app').factory('$requestInjector', [
- '_',
- function(_) {
- var injector = {
- request: function(config) {
- var current_user = localStorage.getItem('current_user');
- if(!_.isEmpty(current_user)){
- var username = current_user.username;
- var password = current_user.password;
- var authToken = btoa(username + ':' + password);
- config.headers['Authorization'] = 'Basic ' + authToken;
- }
- return config;
- }
- };
- return injector;
- }
- ]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement