Sha256: a7bfaea7e444d41c38d4aa7744b2475725b12360beebbae8311e6011d0b3b1d6

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

(function(conjur, $, async, errback) {
    'use strict';

    var Generic = this.Generic;

    var User = this.User = function(args) {
        if (!(this instanceof User)) {
            return new User(args);
        }

        var superArguments = Array.prototype.slice.call(arguments);
        superArguments.unshift('user');
        Generic.apply(this, superArguments);

        return undefined;
    };

    User.prototype = Object.create(Generic.prototype);
    User.prototype.constructor = User;

    User.prototype.publicKeys = function(callback, custom_errback) {
        $.ajax({
            url: '/api/pubkeys/' + window.encodeURIComponent(this.id),
            success: function(data) {
                callback(null, data.split('\n').filter(function(d) {
      	            return d.trim().length > 0;
                }));
            },
            error: callback
        });
    };

    User.prototype.fetch = function(callback, custom_errback) {
        var self = this,
            id = this.id;

        if (typeof(custom_errback) === 'undefined') {
            custom_errback = errback; // reset to default
        }

        async.parallel([
            this.attributes.bind(this),
            this.ownedResources.bind(this),
            this.allRoles.bind(this),
            this.resource.bind(this),
            this.publicKeys.bind(this)
        ], function(err, results) {
            if (err) {
                return custom_errback(err.status);
            }

            callback({
                user: results[0],
                owned: results[1],
                roles: results[2],
                annotations: results[3].annotations,
                pubkeys: results[4]
            });

            return undefined;
        });
    };

}).bind(conjur.models.Record)
(
    conjur,
    jQuery,
    async,
    conjur.utils.errback
);

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
conjur-asset-ui-1.3.2 public/js/models/userRecord.js
conjur-asset-ui-1.3.0 public/js/models/userRecord.js