mnubo-sdk
Version:
mnubo SmartObjects JavaScript client
18 lines (14 loc) • 419 B
text/typescript
export function authenticate(target: Object, key: string, descriptor: any) {
const value = descriptor.value;
descriptor.value = function() {
const args = arguments;
if (!this.client.options.token) {
return this.client.authenticate().then(() => {
return value.apply(this, args);
});
} else {
return Promise.resolve(value.apply(this, args));
}
};
return descriptor;
}