コード例 #1
0
        public static Credentials createFromAccount(Accounts account)
        {
            Credentials cred = new Credentials();
            cred.acctType = account.acctType;
            cred.fName = account.fName;
            cred.lName = account.lName;
            cred.UserName = account.Username;
            cred.ID = account.ID;

            cred.Password = "";

            return cred;
        }
コード例 #2
0
        public ActionResult Login(Credentials model, string returnUrl)
        {
            if (Accounts.IsValid(model.UserName, model.Password, db))
            {

                string accType = Accounts.findType(model.UserName, model.Password, db);

                var profileData = new UserProfileObj(model.UserName, accType);
                string delimited = model.UserName + "&" + accType;
                Session["UserProfile"] = profileData;
                FormsAuthentication.SetAuthCookie(delimited, true);
                Session["role"] = model.UserName;

                return RedirectToAction("Index", "Home");
            }
            else
            {
                return View();
            }

            // If we got this far, something failed, redisplay form
        }