Exemple #1
0
        private void EditCredential(NPMCredential credential)
        {
            CredentialManager    thisManager      = credentialManager;
            CredentialEditorView credentialEditor = EditorWindow.GetWindow <CredentialEditorView>(true, "Edit credential", true);

            credentialEditor.Edit(credential, thisManager);
        }
        public CredentialManager()
        {
            if (File.Exists(upmconfigFile))
            {
                var upmconfig = Toml.Parse(File.ReadAllText(upmconfigFile));
                if (upmconfig.HasErrors)
                {
                    Debug.LogError("Cannot load upmconfig, invalid format");
                    return;
                }


                TomlTable table = upmconfig.ToModel();

                TomlTable auth = (TomlTable)table["npmAuth"];
                if (auth != null)
                {
                    foreach (var registry in auth)
                    {
                        NPMCredential cred = new NPMCredential();
                        cred.url = registry.Key;
                        TomlTable value = (TomlTable)registry.Value;
                        cred.token      = (string)value["token"];
                        cred.alwaysAuth = (bool)value["alwaysAuth"];

                        credentials.Add(cred.url, cred);
                    }
                }
            }
        }
 private void UpdateCredential()
 {
     if (controller.credentialManager.HasRegistry(registry.url))
     {
         NPMCredential cred = controller.credentialManager.GetCredential(registry.url);
         registry.auth  = cred.alwaysAuth;
         registry.token = cred.token;
     }
 }
Exemple #4
0
        public void Edit(NPMCredential credential, CredentialManager credentialManager)
        {
            this.credentialManager = credentialManager;
            this.registry          = new ScopedRegistry();
            this.registry.url      = credential.url;
            this.registry.auth     = credential.alwaysAuth;
            this.registry.token    = credential.token;

            this.createNew   = false;
            this.initialized = true;
        }
        internal void SetCredential(string url, bool alwaysAuth, string token)
        {
            if (HasRegistry(url))
            {
                credentials[url].url        = url;
                credentials[url].alwaysAuth = alwaysAuth;
                credentials[url].token      = token;
            }
            else
            {
                NPMCredential newCred = new NPMCredential();
                newCred.url        = url;
                newCred.alwaysAuth = alwaysAuth;
                newCred.token      = token;

                credentials.Add(url, newCred);
            }
        }
        private ScopedRegistry LoadRegistry(JObject Jregistry)
        {
            ScopedRegistry registry = new ScopedRegistry();

            registry.name = (string)Jregistry["name"];
            registry.url  = (string)Jregistry["url"];

            List <string> scopes = new List <string>();

            foreach (var scope in (JArray)Jregistry["scopes"])
            {
                scopes.Add((string)scope);
            }
            registry.scopes = scopes.ToArray();

            if (credentialManager.HasRegistry(registry.url))
            {
                NPMCredential credential = credentialManager.GetCredential(registry.url);
                registry.auth  = credential.alwaysAuth;
                registry.token = credential.token;
            }

            return(registry);
        }
Exemple #7
0
 private void RemoveCredential(NPMCredential credential)
 {
     credentialManager.RemoveCredential(credential.url);
     credentialManager.Write();
 }