public string GetId(Token token, string appSecret)
        {
            if (!ValidateAppSecret(appSecret, Rights.InternalAuth.Common))
                return null;

            var user = LoginHandler.GetLoginByToken(token);

            return user?.Id;
        }
        public Character GetCharacter(Token token, string charId)
        {
            var chars = GetCharacterList(token);
            Character c;

            if (chars == null
                || !chars.TryGetValue(charId, out c))
                return null;

            return c;
        }
        public static User GetUser(this IDictionary<string, User> usersCollection, Token token)
        {
            var id = token.GetUserId();
            User user = null;

            if (id == null
                || !usersCollection.TryGetValue(id, out user))
                return null;

            return user;
        }
 public IDictionary<string, Character> GetCharacterList(Token token) =>
     Users.All
         .GetUser(token)
         ?.Characters;
 public CharacterDescription GetCharacterDescription(Token token, string charId) => GetCharacter(token, charId);
 public IDictionary<string, CharacterDescription> GetCharacterDescriptionList(Token token) =>
     GetCharacterList(token)
         ?.Remap(c => (CharacterDescription)c);
 public bool IsLogged(Token token) => LoginHandler.IsLogged(token);
 public bool Logout(Token token) => LoginHandler.Logout(token);
        public Login GetLoginByToken(Token token)
        {
            Login login;

            if (!_loginsByTokens.TryGetValue(token, out login))
                return null;

            if (login.Token != token)
            {
                _loginsByTokens.Remove(token);
                return null;
            }

            var now = DateTime.Now;
            if (login.Token <= now)
            {
                login.Token = null;
                _loginsByTokens.Remove(token);
                return null;
            }

            return login;
        }
 public bool IsLogged(Token token)
 {
     return GetLoginByToken(token) != null;
 }
        public bool Logout(Token token)
        {
            var login = GetLoginByToken(token);

            if (login == null)
                return false;

            login.Token = null;
            _loginsByTokens.Remove(token);
            return true;
        }