Ejemplo n.º 1
0
        public static CGeneralUser ForgotPassword(string Username, string Email)
        {
            CGeneralUser oResult = new CGeneralUser();

            try
            {
                CShared oDBShared = new CShared();
                DataSet dsLogin   = oDBShared.GetDataSet("TForgotPassword", "uspForgotPassword '" + Username + "', '" + Email + "'");

                using (DataTable dtForgot = dsLogin.Tables["TForgotPassword"])
                {
                    if (dtForgot != null && dtForgot.Rows.Count > 0)
                    {
                        if (Convert.ToBoolean(dtForgot.Rows[0]["Success"]))
                        {
                            // SEND EMAIL INCULUDING PASSCODE ON USER'S EMAIL ADDRESS
                            string sUserEmail = dtForgot.Rows[0]["Email"].ToString();

                            string sPasscode  = CShared.GetDecryptString(dtForgot.Rows[0]["Password"].ToString());
                            string sEmailBody = "<p>Greetings, <p>" +
                                                "<p>This is your passcode: <b> " + sPasscode + "</b> for Ornament Application.<p>" +
                                                "<p>Please use this passcode and login with Ornament app!<p>" +
                                                "<p>Regards,</p>" +
                                                "<p>Invisible Fiction.</p>";

                            //SEND EMAIL WITH NEW PASSWORD
                            oDBShared.SendEmail("Forgot Password|" + sUserEmail + "", "", "", "Your Passcode For Ornament App.", sEmailBody);

                            oResult.Success       = Convert.ToBoolean(dtForgot.Rows[0]["Success"]);
                            oResult.WasSuccessful = Convert.ToInt32(dtForgot.Rows[0]["Success"]);
                            oResult.Exception     = dtForgot.Rows[0]["ErrorSuccessMsg"].ToString();
                        }
                        else
                        {
                            oResult.Success       = Convert.ToBoolean(dtForgot.Rows[0]["Success"]);
                            oResult.WasSuccessful = Convert.ToInt32(dtForgot.Rows[0]["Success"]);
                            oResult.Exception     = dtForgot.Rows[0]["ErrorSuccessMsg"].ToString();
                        }
                    }
                }
                return(oResult);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }