示例#1
0
        /// <summary>
        /// Get encoder.
        /// </summary>
        /// <param name="useAuthorisationCode">Should the authorisation code be used.</param>
        /// <returns>The password encoder.</returns>
        public static Nequeo.Cryptography.IPasswordEncryption GetEncoder(bool useAuthorisationCode = true)
        {
            Nequeo.Security.Configuration.Reader    reader  = new Security.Configuration.Reader();
            Nequeo.Cryptography.IPasswordEncryption encoder = reader.GetEncoder();

            // Return the encoder.
            return(encoder);
        }
示例#2
0
        /// <summary>
        /// Validate the user
        /// </summary>
        /// <param name="loginUserName">The login username</param>
        /// <param name="loginPassword">The login password</param>
        /// <returns>The validated user; else null</returns>
        public virtual Edm.User Validate(string loginUserName, string loginPassword)
        {
            Edm.User user = null;

            try
            {
                // Encode password.
                Nequeo.Security.Configuration.Reader    reader  = new Security.Configuration.Reader();
                Nequeo.Cryptography.IPasswordEncryption encoder = reader.GetEncoder();

                // Encode the password.
                string encodedPassword = encoder.Encode(loginPassword, encoder.PasswordFormat);

                // Get the user for the credentials.
                user = Select.SelectIQueryableItems(
                    u =>
                    (u.LoginUserName == loginUserName) &&
                    (u.LoginPassword == encodedPassword)).First();
            }
            catch { user = null; }

            // Return the user.
            return(user);
        }