/// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        protected override object MainProcess() {
            var auth = base.MainProcess().ToDict();


            var salt = auth["Salt"].ToString();

            if (!RuTokenAuthAction.Sessions.Any(_ => _.ToDict()["Salt"].ToString() == salt)) {
                throw new Exception("Salt misatch");
            }

            var user = RuTokenAuthAction.Sessions.FirstOrDefault(_ => _.ToDict()["Salt"].ToString() == salt);
            if (
                user.ToDict()["Role"].ToString() != "ADMIN"
            ) {
                throw new Exception("permission denied");
            }
            
            var config = new JsonParser().ParseXml(Config);

            foreach (var el in config.XPathSelectElements("//item")) {
                var tokenId = el.Attribute("TokenId").TryGetValue();

                if (!BuiltInTokens.TokenExists(tokenId)) {
                    continue;
                }

                var tconfig = BuiltInTokens.GetConfig(tokenId);

                if (tconfig["Role"].ToString() == "ADMIN") {
                    continue;
                }

                var clause = new {
                    Activated = (el.Attribute("Activated").TryGetValue() == "true"),
                    Comment = el.Attribute("Comment").TryGetValue(),
                    Username = BuiltInTokens.InternalUsername(tokenId),
                    FakeUsername = el.Attribute("Username").TryGetValue()
                } as object;

                if (tconfig["Role"].ToString() == "DEV") {
                    clause = new {
                        Activated = (el.Attribute("Activated").TryGetValue() == "true"),
                        Comment = tconfig["Comment"].ToString(),
                        Username = BuiltInTokens.InternalUsername(tokenId),
                        FakeUsername = BuiltInTokens.InternalUsername(tokenId)
                    } as object;
                }

                UsersStorage.UpdateConfig(tokenId, clause);
            }

            return new {Success = true};
        }
示例#2
0
		public void ItsNotReproducedNow() {
			var parser = new JsonParser();
			var xml = parser.ParseXml(@"{""0"":{""id"":""5:5"",""value"":""1"",""ri"":""m1111111_Б2_2013_2""}}");
			Console.WriteLine(xml);
		}