This repository was archived by the owner on Nov 25, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(value-converters): move/rename/add valueConverters
isAuth(isAuthenicated): isAuthenicated is optional. defaults to authService.authenticated authenticated(): valueConverted added. returns authService.authenticated made configurable which value converters should be global
- Loading branch information
1 parent
caf4a3b
commit 4d2ee93
Showing
7 changed files
with
58 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import {inject} from 'aurelia-dependency-injection'; | ||
import {AuthService} from './authService'; | ||
|
||
@inject(AuthService) | ||
export class AuthFilterValueConverter { | ||
constructor(authService) { | ||
this.authService = authService; | ||
} | ||
|
||
/** | ||
* route toView predictator on route.config.auth === (parameter || authService.isAuthenticated()) | ||
* @param {RouteConfig} routes the routes array to convert | ||
* @param {[Boolean]} [isAuthenticated] optional isAuthenticated value. default: this.authService.authenticated | ||
* @return {Boolean} show/hide element | ||
*/ | ||
toView(routes, isAuthenticated = this.authService.authenticated) { | ||
return routes.filter(route => route.config.auth === isAuthenticated); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {inject} from 'aurelia-dependency-injection'; | ||
import {AuthService} from './authService'; | ||
|
||
@inject(AuthService) | ||
export class AuthenticatedValueConverter { | ||
constructor(authService) { | ||
this.authService = authService; | ||
} | ||
|
||
/** | ||
* element toView predictator on authService.isAuthenticated() | ||
* @return {Boolean} show/hide element | ||
*/ | ||
toView() { | ||
return this.authService.authenticated; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters