Esempio n. 1
0
        public ActionResult ManageUserPartial()
        {
            if (User.Identity.IsAuthenticated)
            {
                string loginName = User.Identity.Name;
                UserManagerFK UM = new UserManagerFK();
                UserDataView UDV = UM.GetUserDataView(loginName);
                return PartialView(UDV);
            }

            return View();
        }
Esempio n. 2
0
 protected override bool AuthorizeCore(HttpContextBase httpContext)
 {
     bool authorize = false;
     using (ECommerceEntities db = new ECommerceEntities())
     {
         UserManagerFK UM = new UserManagerFK();
         foreach(var roles in userAssignedRoles)
         {
             authorize = UM.IsUserInRole(httpContext.User.Identity.Name, roles);
             if (authorize)
                 return true;
         }
     }
     return authorize;
 }
Esempio n. 3
0
        public ActionResult Login(UserLogin ULV)
        {
            if (ModelState.IsValid)
            {
                UserManagerFK UM = new UserManagerFK();
                PasswordManager PM = new PasswordManager();

                string Password = UM.GetUserPassword(ULV.UserName);

                if (string.IsNullOrEmpty(Password))
                {
                    ModelState.AddModelError("", "Login Failed, Details Provided Are Incorrect.");
                }
                else
                {
                    if (/*PM.Encrypt*/(ULV.Password).Equals(Password))
                    {
                        FormsAuthentication.SetAuthCookie(ULV.UserName, false);
                        return RedirectToAction("Welcome", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Password Is Incorrect.");
                    }
                }
            }
            return View(ULV);
        }
Esempio n. 4
0
        public ActionResult SignUp(UserModel USV, AddressModel AM)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    UserManagerFK UM = new UserManagerFK();

                    if (!UM.IsLoginNameExist(USV.Username) || !UM.IsEmailExist(USV.Email))
                    {
                        UM.AddUserAccount(USV, AM);
                        FormsAuthentication.SetAuthCookie(USV.FirstName, false);
                        return RedirectToAction("Welcome", "Home");
                    }
                    else
                    {
                        ModelState.AddModelError("", "Username already taken.");
                    }
                }
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            return View();
        }
Esempio n. 5
0
 public ActionResult ResetPassword(ResetPassword2 RP)
 {
     if (ModelState.IsValid)
     {
         UserManagerFK UM = new UserManagerFK();
         string url = Request.Url.AbsoluteUri;
         string query = Request.Url.Query;
         var routeValueDictionary = RouteData.Values["id"];
         UM.UpdateUserPassword(RP.EmailAddress, RP.Password);
     }
     return View(RP);
 }
Esempio n. 6
-1
        public ActionResult ForgotPassword(ForgotPasswordViewModelMyOwn model)
        {
            if (ModelState.IsValid)
            {
                ResetPassword RP = new ResetPassword();
                UserModel UM = new UserModel();
                UserManagerFK UMF = new UserManagerFK();
                string email = UMF.GetUserEmail(model.UserName);

                if (email == null)
                {

                    return View("ForgotPasswordConfirmation");
                }

                Guid EMailCode = Guid.NewGuid();
                var callbackUrl = Url.Action("ResetPassword", "UserAccount", new { userId = email, code = EMailCode }, protocol: Request.Url.Scheme);

                UMF.AddResetPasswordDetails(EMailCode, email, "Y");

                //SmtpClient SmtpClient = new SmtpClient("smtp.gmail.com");
                //MailAddressCollection MailAddressCollection = new MailAddressCollection();
                //MailMessage message = new MailMessage();
                //message.From = new MailAddress("*****@*****.**", "Faheem Kathrada");
                //message.Body = "Please reset your password by clicking < a href =\"" + callbackUrl + "\">here</a>";
                //message.Subject = "Nexidia Log Files";
                //message.To.Add("*****@*****.**");

                //SmtpClient.Port = 587;
                //SmtpClient.EnableSsl = true;
                //SmtpClient.Send(message);
                //message.Dispose();

                var client = new SmtpClient("smtp.gmail.com", 587)
                {
                    Credentials = new NetworkCredential("*****@*****.**", "8September@008"),
                    EnableSsl = true
                };
                client.Send("*****@*****.**", "*****@*****.**", "Password Reset", "Please reset your password by clicking < a href =\"" + callbackUrl + "\">here</a>");

                return RedirectToAction("ForgotPasswordConfirmation", "Account");
            }

            return View(model);
        }