1

I need to generate an unique link, so that when user clicks on it, they end up on some page. However, they can't go directly to that page just by typing a simple URL on address bar.

Usecase: For example beta access to some site. Users submit a request and then admin emails them with a unique link that can be used to access signup page.

How can this be achieved in Angular 2?

Billy Logan
  • 2,470
  • 6
  • 27
  • 45

1 Answers1

0

you can achieve this in many ways, but the easiest way is to pass in a token and validate the token on the server

So anguler's route looks like this

$routeProvider.when('/page', { templateUrl: 'views/page.html', controller: 'pageController'})

and in the page controller

app.controller('reportDetailViewController', function($scope, $routeParams) {
   $scope.token = $token;
   if(isValid($scope.token)){
     // show page
   }else{
     // redirect/hide
   }
}

to call the specific page, you can simply pass the token in the GET like

http://yoursite/app?token=aqw481iue
xxfast
  • 697
  • 5
  • 14
  • 3
    This syntax is for Angular 1. Billy Logan asked about Angular 2. – AngularChef Feb 23 '17 at 08:03
  • 2
    Here is a link for how to use Angular 2 syntax, just apply that to Isuru's answer. http://stackoverflow.com/questions/34599174/how-to-handle-query-parameters-in-angular-2 – Dan Simon Feb 23 '17 at 08:10