How to use the formiojs.currentUser function in formiojs

To help you get started, we’ve selected a few formiojs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github formio / angular-formio / src / modules / auth / auth.service.ts View on Github external
// 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));
  }
github formio / angular-formio / dist / modules / auth / auth.service.js View on Github external
});
        // 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) {
github formio / react-formio / src / providers / FormioAuth / actions.js View on Github external
return (dispatch, getState) => {
      dispatch(requestUser());

      formiojs.currentUser()
        .then((result) => {
          dispatch(receiveUser(result));
          getAccess(dispatch, getState);
        })
        .catch((result) => {
          dispatch(failUser(result));
        });
    };
  },