|
|
@@ -1,13 +1,4 @@
|
|
1
|
|
-### User Sign Up
|
|
2
|
|
-
|
|
3
|
|
-1. User arrives at home page
|
|
4
|
|
-2. User fills out bare minimum information to create profile
|
|
5
|
|
-3. User is emailed a verification email
|
|
6
|
|
-4. User clicks on transactional email
|
|
7
|
|
-5. User is redirected to application
|
|
8
|
|
-6. User is logged in and presented with home screen
|
|
9
|
|
-
|
|
10
|
|
-### User Arrives at Application
|
|
|
1
|
+### The LifeCycle Check Of Initial Auth Check For Siimee
|
|
11
|
2
|
|
|
12
|
3
|
1. Upon first arrival at the Siimee application, the Vue Router's guards are
|
|
13
|
4
|
called in the router.beforeEach() method. A simple conditional checks to see
|
|
|
@@ -392,3 +383,52 @@ async function log(to) {
|
|
392
|
383
|
console.info("[Guard Status debug]: being routed to:", to.fullPath);
|
|
393
|
384
|
}
|
|
394
|
385
|
```
|
|
|
386
|
+
|
|
|
387
|
+22. A series of conditional statements then check against each route within the
|
|
|
388
|
+ Vue Router's configuration file, router/index.js which each subsequently
|
|
|
389
|
+ check the to (called destination) route, which checks it's
|
|
|
390
|
+ meta.requiresCompleteProfile as well as the meta.requiresAuth fields.
|
|
|
391
|
+ Additionally, the currentProfile.isLoggedIn and currentProfile.isComplete
|
|
|
392
|
+ fields are also checked. Should the route require a complete profile, but
|
|
|
393
|
+ the user's is not logged in or the user's currentProfile not yet be
|
|
|
394
|
+ completed, the user is redirected to the /onboarding route, which for the
|
|
|
395
|
+ sake of this documentation, is the assumed state. Thusly let us move onto
|
|
|
396
|
+ the /onboarding route, the corresponding Vue component to our /onboarding route,
|
|
|
397
|
+ as defined in our router/index.js file is the OnboardingView component.
|
|
|
398
|
+
|
|
|
399
|
+```javascript
|
|
|
400
|
+// src/router/guards.js line 32
|
|
|
401
|
+const checkLoginStatus = async (destination, nextCb) => {
|
|
|
402
|
+ await loginIfToken();
|
|
|
403
|
+ log(destination);
|
|
|
404
|
+ if (DEV_MODE) {
|
|
|
405
|
+ nextCb();
|
|
|
406
|
+ } else if (
|
|
|
407
|
+ destination.meta.requiresCompleteProfile &&
|
|
|
408
|
+ !currentProfile.isLoggedIn &&
|
|
|
409
|
+ !currentProfile.isComplete
|
|
|
410
|
+ ) {
|
|
|
411
|
+ nextCb("/onboarding");
|
|
|
412
|
+ } else if (
|
|
|
413
|
+ destination.meta.requiresCompleteProfile &&
|
|
|
414
|
+ destination.meta.requiresAuth &&
|
|
|
415
|
+ !currentProfile.isLoggedIn
|
|
|
416
|
+ ) {
|
|
|
417
|
+ nextCb("/login");
|
|
|
418
|
+ } else {
|
|
|
419
|
+ nextCb();
|
|
|
420
|
+ }
|
|
|
421
|
+};
|
|
|
422
|
+
|
|
|
423
|
+export { checkLoginStatus };
|
|
|
424
|
+```
|
|
|
425
|
+
|
|
|
426
|
+```javascript
|
|
|
427
|
+// src/router/index.js, line 63
|
|
|
428
|
+{
|
|
|
429
|
+ path: `/onboarding/`,
|
|
|
430
|
+ component: OnboardingView,
|
|
|
431
|
+ name: `OnboardingView`,
|
|
|
432
|
+ meta: { requiresAuth: true, requiresCompleteProfile: false },
|
|
|
433
|
+},
|
|
|
434
|
+```
|