示例#1
0
        public async Task <ActionResult <VendorLogin> > PostVendorLogin(VendorLogin vendorLogin)
        {
            _context.VendorLogin.Add(vendorLogin);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetVendorLogin", new { id = vendorLogin.ID }, vendorLogin));
        }
示例#2
0
        public async Task <IActionResult> PutVendorLogin(int id, VendorLogin vendorLogin)
        {
            if (id != vendorLogin.ID)
            {
                return(BadRequest());
            }

            _context.Entry(vendorLogin).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!VendorLoginExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        public ActionResult Login(VendorLogin login, string returnUrl = "")
        {
            string message;

            using (CompanyEntities4 dc = new CompanyEntities4())
            {
                //To a.EmailID = είναι το mail που υπαρχει στη βαση μας, Το login.EmailID = είναι το mail που εχει πληκτρολογησει η χρήστης
                var v = dc.Vendors.FirstOrDefault(a => a.Email == login.Email); //επιστρεφει ΟΛΑ τα στοιχεια του χρήστη με το συγκεκριμένο email
                if (v != null && v.IsEmailVerified)                             //εαν υπάρχει αυτό το mail και αρα και ο χρήστης..., και το mail εχει επιβεβαιωθει
                {
                    //Συκρινε το password που πληκτρολογησε ο χρήσης(login.PassWord) με το password που υπάρχει στη βάση(v.PassWord)
                    if (string.CompareOrdinal(Crypto.Hash(login.Password), v.Password) == 0)
                    {
                        //εαν εχει τσεκαριστει το login.Rememberme(TRUE), τοτε ο χρόνος αναμονής θα είναι 525600 αλλιως θα είναι 20 min(να αποσυνδεθεις δηλ σε 20 min)
                        //SOS ΚΡΑΤΑΕΙ ΤΟ SESSION
                        int timeout   = login.RememberMe ? 525600 : 20;                                        //525600 min = 1 year
                        var ticket    = new FormsAuthenticationTicket(login.Email, login.RememberMe, timeout); //το ticket θα εχει ονομα(στην περιπτωση μας το email), εαν θα ειναι μονιμο, και ο χρονος λήξης του
                        var encrypted = FormsAuthentication.Encrypt(ticket);                                   //το κρυπτογραφούμε
                        var cookie    =
                            new HttpCookie(FormsAuthentication.FormsCookieName, encrypted)                     // πέρνουμε μονο το όνομα (το mail στην περιπτωση μας), και την τιμη του(κρυπτογραφημενη)
                        {
                            Expires  = DateTime.Now.AddMinutes(timeout),                                       //ποτε λήγει
                            HttpOnly = true
                        };
                        Response.Cookies.Add(cookie);

                        if (Url.IsLocalUrl(returnUrl))
                        {
                            return(Redirect(returnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        message = "Invalid credential provided";
                    }
                }
                else
                {
                    message = "Invalid credential provided1";
                }
            }


            ViewBag.Message = message;

            return(View());
        }
        public ActionResult Login(VendorLogin login, string ReturnUrl)
        {
            string message = "";

            using (FinalDatabaseEntities1 dc = new FinalDatabaseEntities1())
            {
                var c = dc.Vendors.Where(a => a.Email_id == login.email_id).FirstOrDefault();
                if (c != null)
                {
                    if (string.Compare(Crypto.Hash(login.password), c.password) == 0)
                    {
                        int    timeout   = login.RememberMe ? 525600 : 20;
                        var    ticket    = new FormsAuthenticationTicket(login.email_id, login.RememberMe, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;
                        Response.Cookies.Add(cookie);
                        return(RedirectToAction("Index"));

                        /*if (Url.IsLocalUrl(ReturnUrl))
                         * {
                         *  return Redirect(ReturnUrl);
                         * }
                         * else
                         * {
                         *  return RedirectToAction("Index", "Home");
                         * }*/
                    }
                    else
                    {
                        //message = "Invalid credential provided";
                        ModelState.AddModelError("", "The username or password is incorrect");
                    }
                }
                else
                {
                    //message = "Invalid credential provided";
                    ModelState.AddModelError("", "The username or password is incorrect");
                }
            }
            //ViewBag.Message = message;
            return(View());
        }
示例#5
0
        public ActionResult Login(VendorLogin login, string ReturnUrl)
        {
            string message = "";

            using (vendorEntities dc = new vendorEntities())
            {
                var v = dc.Vendors.Where(a => a.Email == login.Email).FirstOrDefault();
                if (v != null)
                {
                    if (string.Compare(Crypto.Hash(login.Password), v.Password) == 0)
                    {
                        int    timeout   = login.RememberMe ? 525600 : 1; //525600 min = 1 year
                        var    ticket    = new FormsAuthenticationTicket(login.Email, login.RememberMe, timeout);
                        string encrypted = FormsAuthentication.Encrypt(ticket);
                        var    cookie    = new HttpCookie(FormsAuthentication.FormsCookieName, encrypted);
                        cookie.Expires  = DateTime.Now.AddMinutes(timeout);
                        cookie.HttpOnly = true;
                        Response.Cookies.Add(cookie);

                        if (Url.IsLocalUrl(ReturnUrl))
                        {
                            return(Redirect(ReturnUrl));
                        }
                        else
                        {
                            return(RedirectToAction("Index", "Home"));
                        }
                    }
                    else
                    {
                        message = "Invalid credential provided";
                    }
                }
                else
                {
                    message = "Invalid credential provided";
                }
            }
            ViewBag.Message = message;
            return(View());
        }