Ejemplo n.º 1
0
        public ActionResult Auth()
        {
            var yandex = YandexAuth.GetUser(Request);
            var mail   = MailAuth.GetUser(Request);

            return(PartialView("AuthPartialView", mail));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Сюда приходит после авторизации на Mail
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginWithMail()
        {
            var model = MailAuth.GetToken(Request);

            var userCookie = MailAuth.TokenCookie(model);

            Response.Cookies.Set(userCookie);

            return(RedirectToActionPermanent("Index", "Home"));
        }
Ejemplo n.º 3
0
        public ActionResult MailAuth(string email)
        {
            string myMail = email;

            Session["authMail"] = email;
            MailAuth ma = new MailAuth();

            try
            {
                Random      random   = new Random();
                int         password = random.Next(1000, 100000000);
                MailMessage msg      = new MailMessage();
                msg.From = new MailAddress("*****@*****.**");
                msg.To.Add(myMail);
                msg.Subject = "PSTU Information System- Create Account";
                msg.Body    = "Dear User !!! Thanks For Your Interest. Your Security Code is " + password + ". Please Enter This Code For Creating Your Account.";
                SmtpClient sc = new SmtpClient("smtp.gmail.com");
                sc.Port        = 25;
                sc.Credentials = new NetworkCredential("*****@*****.**", "12357890");
                sc.EnableSsl   = true;
                sc.Send(msg);

                // TO strore in Database

                string confirmationCode = Convert.ToString(password);
                ma.mail = email;
                ma.code = confirmationCode;

                db.MailAuths.Add(ma);
                db.SaveChanges();
            }
            catch (Exception ex)
            {
                return(View("Error: " + ex));
            }

            return(RedirectToAction("CodeAuth"));
        }