Skip to content

Commit 2b91842

Browse files
authored
Merge pull request #29 from daystram/dev
2 parents ae17850 + 91d07fd commit 2b91842

2 files changed

Lines changed: 12 additions & 4 deletions

File tree

ratify-fe/src/auth/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ const refreshAuth = function(destinationPath: string) {
6868
authManager.authorize(true);
6969
};
7070

71-
const authenticatedOnly = function(to: Route, from: Route, next: () => void) {
72-
if (authManager.getToken(ACCESS_TOKEN)) {
71+
const authenticatedOnly = function(to: Route, _: Route, next: () => void) {
72+
if (authManager.isAuthenticated()) {
7373
next();
7474
} else {
7575
refreshAuth(to.fullPath);
@@ -81,7 +81,7 @@ const unAuthenticatedOnly = function(
8181
from: object,
8282
next: () => void
8383
) {
84-
if (!authManager.getToken(ACCESS_TOKEN)) {
84+
if (!authManager.isAuthenticated()) {
8585
next();
8686
} else {
8787
router.push({ name: "manage:dashboard" });

ratify-fe/src/router/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,13 @@ const routes: Array<RouteConfig> = [
4444
},
4545
{
4646
path: "/manage",
47-
beforeEnter: authenticatedOnly,
4847
component: Manage,
4948
redirect: "/manage/dashboard",
5049
children: [
5150
{
5251
path: "dashboard",
5352
name: "manage:dashboard",
53+
beforeEnter: authenticatedOnly,
5454
component: Dashboard,
5555
meta: {
5656
title: "Dashboard | Ratify"
@@ -59,6 +59,7 @@ const routes: Array<RouteConfig> = [
5959
{
6060
path: "profile",
6161
name: "manage:profile",
62+
beforeEnter: authenticatedOnly,
6263
component: Profile,
6364
meta: {
6465
title: "Profile | Ratify"
@@ -67,6 +68,7 @@ const routes: Array<RouteConfig> = [
6768
{
6869
path: "activity",
6970
name: "manage:activity",
71+
beforeEnter: authenticatedOnly,
7072
component: Activity,
7173
meta: {
7274
title: "Activity | Ratify"
@@ -75,6 +77,7 @@ const routes: Array<RouteConfig> = [
7577
{
7678
path: "session",
7779
name: "manage:session",
80+
beforeEnter: authenticatedOnly,
7881
component: Placeholder,
7982
meta: {
8083
title: "WIP:Sessions | Ratify"
@@ -83,6 +86,7 @@ const routes: Array<RouteConfig> = [
8386
{
8487
path: "setting",
8588
name: "manage:setting",
89+
beforeEnter: authenticatedOnly,
8690
component: Placeholder,
8791
meta: {
8892
title: "WIP:Settings | Ratify"
@@ -91,6 +95,7 @@ const routes: Array<RouteConfig> = [
9195
{
9296
path: "user",
9397
name: "manage:user",
98+
beforeEnter: authenticatedOnly,
9499
component: User,
95100
meta: {
96101
title: "WIP:Users | Ratify"
@@ -99,6 +104,7 @@ const routes: Array<RouteConfig> = [
99104
{
100105
path: "application",
101106
name: "manage:application",
107+
beforeEnter: authenticatedOnly,
102108
component: ApplicationList,
103109
meta: {
104110
title: "Applications | Ratify"
@@ -107,6 +113,7 @@ const routes: Array<RouteConfig> = [
107113
{
108114
path: "application/:clientId",
109115
name: "manage:application-detail",
116+
beforeEnter: authenticatedOnly,
110117
component: ApplicationDetail,
111118
meta: {
112119
title: "Application Detail | Ratify"
@@ -115,6 +122,7 @@ const routes: Array<RouteConfig> = [
115122
{
116123
path: "log",
117124
name: "manage:log",
125+
beforeEnter: authenticatedOnly,
118126
component: Log,
119127
meta: {
120128
title: "Logs | Ratify"

0 commit comments

Comments
 (0)