github.com/outbrain/consul@v1.4.5/ui-v2/app/routes/dc/acls.js (about)

     1  import Route from '@ember/routing/route';
     2  import { get } from '@ember/object';
     3  import { inject as service } from '@ember/service';
     4  import WithBlockingActions from 'consul-ui/mixins/with-blocking-actions';
     5  export default Route.extend(WithBlockingActions, {
     6    settings: service('settings'),
     7    feedback: service('feedback'),
     8    repo: service('repository/token'),
     9    actions: {
    10      authorize: function(secret) {
    11        const dc = this.modelFor('dc').dc.Name;
    12        return get(this, 'feedback').execute(() => {
    13          return get(this, 'repo')
    14            .self(secret, dc)
    15            .then(item => {
    16              return get(this, 'settings')
    17                .persist({
    18                  token: {
    19                    AccessorID: get(item, 'AccessorID'),
    20                    SecretID: secret,
    21                  },
    22                })
    23                .then(item => {
    24                  // a null AccessorID means we are in legacy mode
    25                  // take the user to the legacy acls
    26                  // otherwise just refresh the page
    27                  if (get(item, 'token.AccessorID') === null) {
    28                    // returning false for a feedback action means even though
    29                    // its successful, please skip this notification and don't display it
    30                    return this.transitionTo('dc.acls').then(function() {
    31                      return false;
    32                    });
    33                  } else {
    34                    this.refresh();
    35                  }
    36                });
    37            });
    38        }, 'authorize');
    39      },
    40    },
    41  });