假设我有课
class Service {
authenticated = false;
login() {
// login
this.authenticated = true;
}
unauthenticatedMethod() {
// everyone should have access
}
authenticatedMethod() {
// only if authenticated = true
}
}
我想要一个装饰器@authenticated
,可以将其添加到authenticatedMethod
方法中以检查authenticated
变量。