Пример #1
0
        /// <summary>
        /// Validates the username and password.
        /// </summary>
        protected override bool ValidateUser(ConnectedClient client, string username, string password, string instance,
                                             out int userID, out int roleID, out string errMsg)
        {
            if (coreLogic.ValidateUser(username, password, out userID, out roleID, out errMsg))
            {
                if (client.IsLoggedIn)
                {
                    log.WriteAction(Locale.IsRussian ?
                                    "Проверка имени и пароля пользователя {0} успешна" :
                                    "Checking username and password for user {0} is successful", username);
                    return(true);
                }
                else if (roleID == RoleID.Application)
                {
                    log.WriteAction(Locale.IsRussian ?
                                    "Пользователь {0} успешно аутентифицирован" :
                                    "User {0} is successfully authenticated", username);

                    client.IsLoggedIn = true;
                    client.Username   = username;
                    client.UserID     = userID;
                    client.RoleID     = roleID;
                    return(true);
                }
                else
                {
                    errMsg = Locale.IsRussian ?
                             "Недостаточно прав" :
                             "Insufficient rights";
                    log.WriteError(Locale.IsRussian ?
                                   "Пользователь {0} имеет недостаточно прав. Требуется роль Приложение" :
                                   "User {0} has insufficient rights. The Application role required", username);
                    return(false);
                }
            }
            else
            {
                if (client.IsLoggedIn)
                {
                    log.WriteError(Locale.IsRussian ?
                                   "Результат проверки имени и пароля пользователя {0} отрицательный: {1}" :
                                   "Checking username and password for user {0} is not successful: {1}", username, errMsg);
                    return(false);
                }
                else
                {
                    log.WriteError(Locale.IsRussian ?
                                   "Ошибка аутентификации пользователя {0}: {1}" :
                                   "Authentication failed for user {0}: {1}", username, errMsg);
                    return(false);
                }
            }
        }