Наследование: WhiteCore.Framework.Modules.IDataTransferable
Пример #1
0
        /// <summary>
        /// Promotes a user to allow API access.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void PromoteAPIUser(IScene scene, string [] cmd)
        {
            var userName = MainConsole.Instance.Prompt("Name of user <First> <Last>");
            var userAcct = m_registry.RequestModuleInterface <IUserAccountService> ().GetUserAccount(null, userName);

            if (!userAcct.Valid)
            {
                MainConsole.Instance.Error("Sorry! Unable to locate this user.");
                return;
            }

            var authKey = UUID.Random().ToString();

            var apiItem = new APIAuthItem {
                Username = userAcct.Name, KeyDate = DateTime.Now, APIKey = authKey
            };

            apiItem.KeyID = generics.GetGenericCount((UUID)Constants.GovernorUUID, "APIKey") + 1;
            generics.AddGeneric((UUID)Constants.GovernorUUID, "APIKey", authKey, apiItem.ToOSD());

            MainConsole.Instance.InfoFormat("[API]: User {0} {1} - API key : {2}", userAcct.FirstName, userAcct.LastName, authKey);
        }
Пример #2
0
        /// <summary>
        /// Promotes a user to allow API access.
        /// </summary>
        /// <param name="scene">Scene.</param>
        /// <param name="cmd">Cmd.</param>
        void PromoteAPIUser (IScene scene, string [] cmd)
        {
            var userName = MainConsole.Instance.Prompt ("Name of user <First> <Last>");
            var account = m_registry.RequestModuleInterface<IUserAccountService> ().GetUserAccount (null, userName);

            if (account == null) {
                MainConsole.Instance.Error ("Sorry! Unable to locate this user.");
                return;
            }

            var authKey = UUID.Random ().ToString ();

            var apiItem = new APIAuthItem { Username = account.Name, KeyDate = DateTime.Now, APIKey = authKey };
            apiItem.KeyID = generics.GetGenericCount ((UUID)Constants.GovernorUUID, "APIKey") + 1;
            generics.AddGeneric ((UUID)Constants.GovernorUUID, "APIKey", authKey, apiItem.ToOSD ());

            MainConsole.Instance.InfoFormat ("[API]: User {0} {1} - API key : {2}", account.FirstName, account.LastName, authKey);


        }