Example #1
0
        /// <summary>
        /// Check credentials.
        /// </summary>
        /// <param name="phone"></param>
        /// <param name="password"></param>
        /// <returns>
        /// 'n' if normal <br/>
        /// 'a' if account was not found <br/>
        /// 'p' if wrong password <br/>
        /// 'b' if account is banned <br/>
        /// 'd' if account is deactivated.
        /// </returns>
        public static char CheckCredentials(string phone, string password)
        {
            Credential cr             = new Credential();
            bool       accountPresent = CredentialCache.TryGet(phone, out cr);

            if (!accountPresent)
            {
                return('a');
            }
            if (cr.Status == (byte)'b')
            {
                return('b');
            }
            if (cr.Password == password)
            {
                if (cr.Status == (byte)'d')
                {
                    return('d');
                }
                return('n');
            }
            return('p');
        }