3

So I am using ui-Router in my app to pass $stateParams and use them in my controllers in more or less clever ways. Point is, some of these $stateParams that I pass contain sensitive information, like employee ids. Is there a way to hide them in the url? I saw some answers here about params, but I am not 100% sure that this was the problem those answers were addressing.

So just to be clear, I am talking about information passed in the url like this:

.state('detail', {
    url: '/detail/:employeeid/:employeename/:employeeteam',
    templateUrl: 'templates/EmployeeReport.html',
    controller: 'ReportController'
})

I want to hide employeeid, employeename and employeeteam.

Thanks!

2
  • Entity ID is likely not a sensitive information. Sensitive information will be employ social security number for example, user password etc. Entity ID is just the ID of the entity in the database. Commented Jun 22, 2016 at 8:31
  • Surely if they have this information in the first place, they must have access to it? If the JavaScript knows about it, it must have come from the server. Commented Jun 22, 2016 at 8:40

1 Answer 1

4

Yes. You can use params.

Docs - here

So you can modify your state as follows,

.state('detail', {
    url: '/detail',
    templateUrl: 'templates/EmployeeReport.html',
    controller: 'ReportController',
    params: { 
        employeeid: null,   // can initialise to default value
        employeename: null, // can initialise to default value
        employeeteam: null  // can initialise to default value
    }
})

Your controller code can contain the values for employeeid, employeename, employeeteam as $scope variables like,

$scope.idVal = 'id';
$scope.nameVal = 'name';
$scope.teamVal = 'team';

Your HTML will be as follows,

<a ui-sref="detail({
   employeeid:idVal,
   employeename: nameVal,
   employeeteam: teamVal
})"> Details state </a>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.