Add documentation to the guards module.
This commit is contained in:
@@ -61,9 +61,22 @@
|
||||
<code>src/app/_guards/auth.guard.ts</code>
|
||||
</p>
|
||||
|
||||
<p class="comment">
|
||||
<h3>Description</h3>
|
||||
</p>
|
||||
<p class="comment">
|
||||
<p>Auth guard implementation.
|
||||
Dictates access to routes depending on the authentication status.</p>
|
||||
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<p class="comment">
|
||||
<h3>Example</h3>
|
||||
</p>
|
||||
<div class="io-description">
|
||||
</div>
|
||||
|
||||
<section>
|
||||
<h3 id="index">Index</h3>
|
||||
@@ -104,12 +117,14 @@
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="8" class="link-to-prism">src/app/_guards/auth.guard.ts:8</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="17" class="link-to-prism">src/app/_guards/auth.guard.ts:17</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Instantiates the auth guard class.</p>
|
||||
</div>
|
||||
<div>
|
||||
<b>Parameters :</b>
|
||||
<table class="params">
|
||||
@@ -118,6 +133,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -132,6 +148,12 @@
|
||||
No
|
||||
</td>
|
||||
|
||||
<td>
|
||||
<code><ul>
|
||||
<li>A service that provides navigation among views and URL manipulation capabilities.</li>
|
||||
</ul>
|
||||
</code>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -169,14 +191,17 @@
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-line">Defined in <a href="" data-line="12"
|
||||
class="link-to-prism">src/app/_guards/auth.guard.ts:12</a></div>
|
||||
<div class="io-line">Defined in <a href="" data-line="35"
|
||||
class="link-to-prism">src/app/_guards/auth.guard.ts:35</a></div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
<tr>
|
||||
<td class="col-md-4">
|
||||
<div class="io-description"><p>Returns whether navigation to a specific route is acceptable.
|
||||
Checks if the user has uploaded a private key.</p>
|
||||
</div>
|
||||
|
||||
<div class="io-description">
|
||||
<b>Parameters :</b>
|
||||
@@ -186,6 +211,7 @@
|
||||
<td>Name</td>
|
||||
<td>Type</td>
|
||||
<td>Optional</td>
|
||||
<td>Description</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -200,6 +226,13 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Contains the information about a route associated with a component loaded in an outlet at a particular moment in time.
|
||||
ActivatedRouteSnapshot can also be used to traverse the router state tree.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>state</td>
|
||||
@@ -212,6 +245,12 @@
|
||||
</td>
|
||||
|
||||
|
||||
<td>
|
||||
<ul>
|
||||
<li>Represents the state of the router at a moment in time.</li>
|
||||
</ul>
|
||||
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -223,7 +262,8 @@
|
||||
|
||||
</div>
|
||||
<div class="io-description">
|
||||
|
||||
<p>true - If there is an active private key in the user's localStorage.</p>
|
||||
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -235,16 +275,38 @@
|
||||
|
||||
<div class="tab-pane fade tab-source-code" id="c-source">
|
||||
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import { Injectable } from '@angular/core';
|
||||
import {CanActivate, ActivatedRouteSnapshot, RouterStateSnapshot, UrlTree, Router} from '@angular/router';
|
||||
import {ActivatedRouteSnapshot, CanActivate, Router, RouterStateSnapshot, UrlTree} from '@angular/router';
|
||||
|
||||
// Third party imports
|
||||
import { Observable } from 'rxjs';
|
||||
|
||||
/**
|
||||
* Auth guard implementation.
|
||||
* Dictates access to routes depending on the authentication status.
|
||||
*
|
||||
* @implements CanActivate
|
||||
*/
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class AuthGuard implements CanActivate {
|
||||
|
||||
/**
|
||||
* Instantiates the auth guard class.
|
||||
*
|
||||
* @param router - A service that provides navigation among views and URL manipulation capabilities.
|
||||
*/
|
||||
constructor(private router: Router) {}
|
||||
|
||||
/**
|
||||
* Returns whether navigation to a specific route is acceptable.
|
||||
* Checks if the user has uploaded a private key.
|
||||
*
|
||||
* @param route - Contains the information about a route associated with a component loaded in an outlet at a particular moment in time.
|
||||
* ActivatedRouteSnapshot can also be used to traverse the router state tree.
|
||||
* @param state - Represents the state of the router at a moment in time.
|
||||
* @returns true - If there is an active private key in the user's localStorage.
|
||||
*/
|
||||
canActivate(
|
||||
route: ActivatedRouteSnapshot,
|
||||
state: RouterStateSnapshot): Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {
|
||||
|
||||
Reference in New Issue
Block a user