|
18 | 18 | <ul>
|
19 | 19 | <li><a href="#introduction">Introduction</a></li>
|
20 | 20 | <li><a href="#getting-started">Getting Started</a></li>
|
21 |
| - <li><a href="#html5">HTML5 mode</a></li> |
22 | 21 | <li><a href="#howto">How To</a></li>
|
| 22 | + <li><a href="#html5">HTML5 mode</a></li> |
23 | 23 | <li><a href="#configurations">Configurations</a></li>
|
24 | 24 | <li><a href="#customizations">Customizations</a></li>
|
25 | 25 | <li><a href="#events">Events</a></li>
|
@@ -95,50 +95,6 @@ <h2>What does it do?</h2>
|
95 | 95 | </section>
|
96 | 96 |
|
97 | 97 |
|
98 |
| - <section> |
99 |
| - <div class="content"> |
100 |
| - |
101 |
| - <h1 id="html5">HTML5 mode</h1> |
102 |
| - |
103 |
| - |
104 |
| - <h2>HTML5 mode ON</h2> |
105 |
| - |
106 |
| - <p>The oauth directive works just straight when the <a href="https://docs.angularjs.org/guide/$location#general-overview-of-the-api">HTML5 mode</a> is active.</p> |
107 |
| - |
108 |
| - <pre><code><xmp><script> |
109 |
| - angular.module('app').config(function($locationProvider) { |
110 |
| - $locationProvider.html5Mode(true).hashPrefix('!'); |
111 |
| - });</script></xmp></code></pre> |
112 |
| - |
113 |
| - |
114 |
| - <h2>HTML5 mode OFF</h2> |
115 |
| - |
116 |
| - <p>When the HTML5 mode is off add the following snippet of code to your routing provider.</p> |
117 |
| - |
118 |
| -<pre><code><xmp>angular.module('app').config(function ($routeProvider) { |
119 |
| - $routeProvider |
120 |
| - .when('/access_token=:accessToken', { |
121 |
| - template: '', |
122 |
| - controller: function ($location, AccessToken) { |
123 |
| - var hash = $location.path().substr(1); |
124 |
| - AccessToken.setTokenFromString(hash); |
125 |
| - $location.path('/'); |
126 |
| - $location.replace(); |
127 |
| - } |
128 |
| - }) |
129 |
| - ...</xmp></code></pre> |
130 |
| - |
131 |
| - |
132 |
| - <p> |
133 |
| - This code is needed because the fragment that the OAuth 2.0 server returns is recognized |
134 |
| - as the routing path <code>/access_token</code>. For this reason you need to add a routing |
135 |
| - rule catching the access token, parse it and then redirect to the desired view of your app. |
136 |
| - </p> |
137 |
| - |
138 |
| - </div> |
139 |
| - </section> |
140 |
| - |
141 |
| - |
142 | 98 | <section>
|
143 | 99 | <div class="content">
|
144 | 100 |
|
@@ -255,7 +211,7 @@ <h2>AngularJS app definition</h2>
|
255 | 211 | <h2>Activate the HTML5 mode</h2>
|
256 | 212 |
|
257 | 213 | <p>
|
258 |
| - Activate the HTML5 mode to easily catch the access token. |
| 214 | + Activate the HTML5 mode to catch the access token. |
259 | 215 | </p>
|
260 | 216 |
|
261 | 217 | <pre><code><xmp>// app/scripts/app.js
|
@@ -371,6 +327,53 @@ <h2>You're done!</h2>
|
371 | 327 |
|
372 | 328 |
|
373 | 329 |
|
| 330 | + <section> |
| 331 | + <div class="content"> |
| 332 | + |
| 333 | + <h1 id="html5">HTML5 mode</h1> |
| 334 | + |
| 335 | + |
| 336 | + <h2>HTML5 mode ON</h2> |
| 337 | + |
| 338 | + <p>The oauth directive works just straight when the <a href="https://docs.angularjs.org/guide/$location#general-overview-of-the-api">HTML5 mode</a> is active.</p> |
| 339 | + |
| 340 | + <pre><code><xmp><script> |
| 341 | + angular.module('app').config(function($locationProvider) { |
| 342 | + $locationProvider.html5Mode(true).hashPrefix('!'); |
| 343 | + });</script></xmp></code></pre> |
| 344 | + |
| 345 | + |
| 346 | + <h2>HTML5 mode OFF</h2> |
| 347 | + |
| 348 | + <p> |
| 349 | + When the HTML5 mode is off (default setup on AngularJS) add the following |
| 350 | + snippet of code to your routing provider. |
| 351 | + </p> |
| 352 | + |
| 353 | +<pre><code><xmp>angular.module('app').config(function ($routeProvider) { |
| 354 | + $routeProvider |
| 355 | + .when('/access_token=:accessToken', { |
| 356 | + template: '', |
| 357 | + controller: function ($location, AccessToken) { |
| 358 | + var hash = $location.path().substr(1); |
| 359 | + AccessToken.setTokenFromString(hash); |
| 360 | + $location.path('/'); |
| 361 | + $location.replace(); |
| 362 | + } |
| 363 | + }) |
| 364 | + ...</xmp></code></pre> |
| 365 | + |
| 366 | + |
| 367 | + <p> |
| 368 | + This code is needed because the fragment that the OAuth 2.0 server returns is recognized |
| 369 | + as the routing path <code>/access_token</code>. For this reason you need to add a routing |
| 370 | + rule catching the access token, parse it and then redirect to the desired view of your app. |
| 371 | + </p> |
| 372 | + |
| 373 | + </div> |
| 374 | + </section> |
| 375 | + |
| 376 | + |
374 | 377 | <section>
|
375 | 378 | <div class="content">
|
376 | 379 | <h1 id="configurations">Configurations</h1>
|
|
0 commit comments