Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Get the access for this project.
this.accessReady = Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then((access: any) => {
_each(access.forms, (form: any) => {
this.submissionAccess[form.name] = {};
form.submissionAccess.forEach((access: any) => {
this.submissionAccess[form.name][access.type] = access.roles;
});
});
this.roles = access.roles;
return access;
}, (err: any): any => {
this.roles = {};
return null;
});
this.userReady = Formio.currentUser().then((user: any) => {
this.setUser(user);
return user;
});
// Trigger we are redy when all promises have resolved.
this.accessReady
.then(() => this.projectReady)
.then(() => this.userReady)
.then(() => this.readyResolve(true))
.catch((err: any) => this.readyReject(err));
}
});
// Get the access for this project.
this.accessReady = Formio.makeStaticRequest(this.appConfig.appUrl + '/access').then(function (access) {
_each(access.forms, function (form) {
_this.submissionAccess[form.name] = {};
form.submissionAccess.forEach(function (access) {
_this.submissionAccess[form.name][access.type] = access.roles;
});
});
_this.roles = access.roles;
return access;
}, function (err) {
_this.roles = {};
return null;
});
this.userReady = Formio.currentUser().then(function (user) {
_this.setUser(user);
return user;
});
// Trigger we are redy when all promises have resolved.
this.accessReady
.then(function () { return _this.projectReady; })
.then(function () { return _this.userReady; })
.then(function () { return _this.readyResolve(true); })
.catch(function (err) { return _this.readyReject(err); });
};
FormioAuthService.prototype.setUser = function (user) {
return (dispatch, getState) => {
dispatch(requestUser());
formiojs.currentUser()
.then((result) => {
dispatch(receiveUser(result));
getAccess(dispatch, getState);
})
.catch((result) => {
dispatch(failUser(result));
});
};
},