コード例 #1
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new AccountDAO();
         var user   = dao.GetByID(model.UserName);
         var result = dao.Login(model.UserName, Encryptor.MD5Hash(model.Password));
         if (result == 1)
         {
             var acountSession = new AccountLogin();
             acountSession.UserName  = user.UserName;
             acountSession.AccountID = user.IDAcount;
             Session.Add(CommonConstants.ACCOUNT_SESSION, acountSession);
             return(RedirectToAction("Index", "Home"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "Tài khoản không tồn tại");
         }
         else if (result == -2)
         {
             ModelState.AddModelError("", "Mật khẩu không đúng");
         }
         else
         {
             ModelState.AddModelError("", "Đăng nhập không thành công");
         }
     }
     return(View(model));
 }
コード例 #2
0
 public HttpResponseMessage ResetAccount([FromBody] AccountLogin account)
 {
     try
     {
         using (var db = new DB())
         {
             TaiKhoan taiKhoan = db.TaiKhoans.FirstOrDefault(x => x.tentaikhoan == account.emailresetpasswork);
             if (taiKhoan == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Gửi email thất bại! Thông tin email/tên tài khoản không tồn tại"));
             }
             string tokenEncode      = Encode.MD5(account.emailresetpasswork);
             string urlResetPasswork = "http://localhost:54328/Login/ResetPasswork?email=" + account.emailresetpasswork + "&token=" + tokenEncode;
             taiKhoan.linklaylaitaikhoan     = tokenEncode;
             taiKhoan.thoigianyeucaulaylaitk = DateTime.Now.AddDays(1);
             db.SaveChanges();
             MailHelper.SendMailGuest(account.emailresetpasswork, "Lấy lại mật khẩu", "Đường dẫn lấy lại mật khẩu: " + urlResetPasswork);
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Gửi email thất bại! Vui lòng nhập lại thông tin email"));
     }
 }
コード例 #3
0
 public frmNhaCungCap(AccountLogin transmission)
 {
     InitializeComponent();
     EnableTextBox(false);
     LoadDataNCC();
     account = transmission;
 }
コード例 #4
0
 public HttpResponseMessage CheckToken([FromBody] AccountLogin account)
 {
     try
     {
         using (var db = new DB())
         {
             TaiKhoan taiKhoan = db.TaiKhoans.FirstOrDefault(x => x.tentaikhoan == account.emailresetpasswork);
             if (taiKhoan == null)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Token không hợp lệ"));
             }
             if (taiKhoan.thoigianyeucaulaylaitk < DateTime.Now)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Đường link hết hiệu lực"));
             }
             if (taiKhoan.linklaylaitaikhoan != account._token)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Token không còn hiệu lực"));
             }
             return(Request.CreateResponse(HttpStatusCode.OK, new
             {
                 _userName = taiKhoan.tentaikhoan,
                 _token = account._token
             }));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Không thể lấy lại mật khẩu: " + ex.Message));
     }
 }
コード例 #5
0
 public HttpResponseMessage Reset([FromBody] AccountLogin account)
 {
     try
     {
         using (var db = new DB())
         {
             TaiKhoan taiKhoan = db.TaiKhoans.FirstOrDefault(x => x.tentaikhoan == account._userName);
             if (taiKhoan.thoigianyeucaulaylaitk < DateTime.Now) // xóa nhầm
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Đường link hết hiệu lực"));
             }
             if (taiKhoan.linklaylaitaikhoan != account._token)
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Token không còn hiệu lực"));
             }
             if (taiKhoan.matkhau == Encode.MD5(account._password))
             {
                 return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Mật khẩu không thể trùng với mật khẩu cũ"));
             }
             taiKhoan.matkhau = Encode.MD5(account._password);
             db.SaveChanges();
             return(Request.CreateResponse(HttpStatusCode.OK));
         }
     }
     catch (Exception ex)
     {
         return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "Cập nhật thất bại: " + ex.Message));
     }
 }
コード例 #6
0
 // GET: Login
 public ActionResult Index(AccountLogin account)
 {
     if (!string.IsNullOrEmpty(account.PassWord) && !string.IsNullOrEmpty(account.UserName))
     {
         tongcuclamnghiepEntities dataBase = new tongcuclamnghiepEntities();
         var acc = dataBase.m_account.Where(a => a.password == account.PassWord && (a.username == account.UserName || a.email == account.UserName) && a.status == true).FirstOrDefault();
         if (acc != null)
         {
             Session["AccountCookie"] = new AccountCookie()
             {
                 Id = acc.id, UserName = acc.username != null ? acc.username : acc.email, Role_Id = acc.role_id, FullName = acc.fullname
             };
             return(RedirectToAction("Index", "Home"));
         }
         else
         {
             ModelState.AddModelError("", "This account does not exist");
             return(View("~/Views/Login/Index.cshtml"));
         }
     }
     else
     {
         return(View());
     }
 }
コード例 #7
0
        public async Task <IActionResult> OnPostAsync(AccountLogin model)
        {
            Console.WriteLine("Sandra");
            if (ModelState.IsValid)
            {
                var isValid = _professorData.CheckProfessor(model.Username, model.Password); //proveris iz baze
                if (!isValid)
                {
                    ModelState.AddModelError("error", "Ne postoji nastavnik sa unetim korisničkim imenom i/ili lozinkom.");
                    return(View("login"));
                }
                Professor professor = _professorData.FindByUsername(model.Username);
                // Create the identity from the user info
                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role);
                identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, model.Username));
                identity.AddClaim(new Claim(ClaimTypes.Name, model.Username));
                HttpContext.Session.SetString("professor", professor.FirstName + " " + professor.LastName);
                Console.WriteLine(HttpContext.Session.GetString("professor"));
                // Authenticate using the identity
                var principal = new ClaimsPrincipal(identity);
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties { IsPersistent = model.RememberMe });

                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Index"));
        }
コード例 #8
0
ファイル: HomeController.cs プロジェクト: enchman/chatservice
        public IActionResult Login(AccountLogin model)
        {
            Account user = Data.DataContext.Instance.Accounts.First(x => x.Username == model.Username);

            if (user != null)
            {
                if (model.Password.VerifyPassword(user.Password))
                {
                    byte[] localToken;
                    string token = Assistant.GetToken(out localToken);

                    Response.Cookies.Append(CookieOption.TokenName, token);
                    HttpContext.Items[SessionType.Token]     = localToken;
                    HttpContext.Items[SessionType.AccountId] = user.Id;
                    return(RedirectToAction("Index", "Profile", null));
                }
                else
                {
                    return(RedirectToAction("Login"));
                }
            }
            else
            {
                return(RedirectToAction("Login"));
            }
        }
コード例 #9
0
        public ActionResult Login(AccountLoginModel login, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                var user = _readOnlyRepository.FirstOrDefault <AccountLogin>(x => x.Email == login.Email && x.Password == (new Hasher().Encrypt(login.Password)) && !x.Archived);
                if (user != null)
                {
                    FormsAuthentication.SetAuthCookie(login.Email, login.RememberMe);
                    SetAuthenticationCookie(login.Email, user.Role);

                    if (Url.IsLocalUrl(returnUrl) && returnUrl.Length > 1 && returnUrl.StartsWith("/") &&
                        !returnUrl.StartsWith("//") && !returnUrl.StartsWith("/\\"))
                    {
                        return(Redirect(returnUrl));
                    }

                    //JUST to avoid LazyInitialization
                    var userAux = new AccountLogin();
                    userAux.AccountMessages = user.AccountMessages;
                    userAux.Notifications   = user.Notifications;

                    Session["User"] = null;
                    Session["User"] = user;

                    return(RedirectToAction("ToInbox"));
                }
                ModelState.AddModelError("", "The user name or password provided is incorrect or not active.");
            }

            return(View(login));
        }
コード例 #10
0
        public ActionResult Login(LoginAdminModel model)
        {
            if (ModelState.IsValid)
            {
                var dao    = new AccountDAO();
                var result = dao.Login(model.AccName, Encrytor.MD5Hash(model.Password));
                if (result == 1)
                {
                    var acc        = dao.GetByID(model.AccName);
                    var accSession = new AccountLogin();
                    accSession.AccountName = acc.displayname;
                    accSession.AccountID   = acc.id;

                    Session.Add(CommonConstants.ACCOUNT_SESSION, accSession);
                    return(RedirectToAction("Index", "HomeAdmin"));
                }
                else if (result == 0)
                {
                    ModelState.AddModelError("", "Tài khoản không tồn tại !!!");
                }
                else if (result == -1)
                {
                    ModelState.AddModelError("", "Sai mật khẩu. Vui lòng nhập lại !!!");
                }
                else
                {
                    ModelState.AddModelError("", "Đăng nhập không thành công !!!");
                }
            }

            return(View("Index"));
        }
コード例 #11
0
        public AccountLogin checkCookie()
        {
            AccountLogin account = null;
            string       username = string.Empty, password = string.Empty;

            if (Request.Cookies["username"] != null)
            {
                username = Request.Cookies["username"].Value;
            }

            if (Request.Cookies["password"] != null)
            {
                password = Request.Cookies["password"].Value;
            }

            if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password))
            {
                account = new AccountLogin {
                    Username = username, Password = password
                }
            }
            ;

            return(account);
        }
    }
コード例 #12
0
ファイル: ProfilePrivacy.cs プロジェクト: sp0ok3r/Mercury
        private void ProfilePrivacy_Load(object sender, EventArgs e)
        {
            CollectPrivacySettings.RunWorkerAsync();
            btn_changeprofSettings.Enabled = false;

            AccountLogin.GetPrivacySettings();
        }
コード例 #13
0
ファイル: MsgRecipients.cs プロジェクト: sp0ok3r/Mercury
        public void RefreshRecipients()
        {
            FriendsList_Grid.Rows.Clear();
            foreach (var f in AccountLogin.Friends)
            {
                var Name = AccountLogin.GetPersonaName(f.ConvertToUInt64());

                var  list = JsonConvert.DeserializeObject <RootObject>(File.ReadAllText(Program.AccountsJsonFile));
                bool ui   = false;
                foreach (var a in list.Accounts)
                {
                    if (a.username == AccountLogin.CurrentUsername)
                    {
                        if (a.MsgRecipients == null)
                        {
                        }
                        if (a.MsgRecipients.Any(s => s.Contains(f.ConvertToUInt64().ToString())))
                        {
                            ui = true;
                        }
                    }
                }

                string[] row = { f.ConvertToUInt64().ToString(), Name, ui.ToString() };
                FriendsList_Grid.Rows.Add(row);
            }
        }
コード例 #14
0
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var result = accountService.Login(model.Email, Encryptor.EncodePasswordToBase64(model.Password));
                if (result == 1)
                {
                    var user = accountService.GetByEmail(model.Email);

                    var employee    = employeeService.GetByID(user.UserID);
                    var userSession = new AccountLogin();
                    userSession.Email       = user.Email;
                    userSession.AccountID   = user.AccountID;
                    userSession.UserID      = user.UserID;
                    userSession.FullName    = employee.FullName;
                    userSession.AccountType = user.AccountType;
                    Session.Add(CommonConstants.USER_SESSION, userSession);
                    if (user.AccountType == 2)
                    {
                        return(RedirectToAction("Index", "ProjectManager"));
                    }
                    else
                    {
                        return(RedirectToAction("Index", "ReportAdmin", new { area = "Admin" }));
                    }
                }
                else
                {
                    ModelState.AddModelError("", "Tài khoản sai hoặc không tồn tại!");
                }
            }
            return(View("Index"));
        }
コード例 #15
0
 public Installation(InstallationId id, AccountType targetType, AccountLogin targetAccount, IEnumerable <RepositoryFullName> repositories)
 {
     Id            = id;
     TargetType    = targetType;
     TargetAccount = targetAccount;
     Repositories  = repositories;
 }
コード例 #16
0
        public async Task <IActionResult> OnPostAsync(AccountLogin model)
        {
            Console.WriteLine("krenuo login");
            if (ModelState.IsValid)
            {
                var isValid = _nastavnikData.ProveriNastavnika(model.Username, model.Password); //proveris iz baze
                Console.WriteLine("isValid:       " + isValid);
                if (!isValid)
                {
                    Console.WriteLine("uslo u greskuuu ");
                    ModelState.AddModelError("error", "Ne postoji nastavnik sa unetim korisničkim imenom i/ili lozinkom.");
                    return(View("login"));
                }
                Nastavnik nastavnik = _nastavnikData.VratiPoUsername(model.Username);
                // Create the identity from the user info
                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme, ClaimTypes.Name, ClaimTypes.Role);
                identity.AddClaim(new Claim(ClaimTypes.NameIdentifier, model.Username));
                identity.AddClaim(new Claim(ClaimTypes.Name, model.Username));
                HttpContext.Session.SetString("nastavnik", nastavnik.Ime + " " + nastavnik.Prezime);
                Console.WriteLine(HttpContext.Session.GetString("nastavnik"));
                // Authenticate using the identity
                var principal = new ClaimsPrincipal(identity);
                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, principal, new AuthenticationProperties { IsPersistent = model.RememberMe });

                return(RedirectToAction("Index", "Home"));
            }

            return(RedirectToAction("Index"));
        }
コード例 #17
0
ファイル: LoginsController.cs プロジェクト: vsvtvpvn/123
        public IHttpActionResult PostTaiKhoans([FromBody] AccountLogin u)
        {
            // taiKhoan = "*****@*****.**"
            // pass = "******"
            var exProc = db.Database.SqlQuery <int>("exec Login_CheckAccount @NameOrEmail, @Password",
                                                    new SqlParameter("NameOrEmail", u.email),
                                                    new SqlParameter("Password", u.matKhau)).ToArray();
            //IEnumerable<string> result = res;
            int kq = exProc[0];

            if (kq == 0)
            {
                TaiKhoan a = new TaiKhoan();
                // kq == 0 hay false : Nghia la tai khoan, mat khau sai
                // Dang nhap Failed
                return(Ok(a));
            }
            else
            {
                // kq == 1 hay true : Nghia la tai khoan, mat khau dung
                // Dang nhap Success
                var exProcSelectAccount = db.Database.SqlQuery <TaiKhoan>("exec Login_SelectAccount @NameOrEmail, @Password",
                                                                          new SqlParameter("NameOrEmail", u.email),
                                                                          new SqlParameter("Password", u.matKhau)).ToList();
                //IEnumerable<string> result = res;
                var accoutn = exProcSelectAccount[0];
                return(Ok(accoutn));
            }
        }
コード例 #18
0
 public IActionResult Login(AccountLogin model)
 {
     if (model.UserName == null || model.Password == null || model.UserName.Trim() == "" || model.Password.Trim() == "")
     {
         TempData["MessageError"] = "Thông tin đăng nhập không được để trống";
     }
     else
     {
         model.UserName = model.UserName.Trim();
         HttpContext.Session.SetString("LoginError", HttpContext.Session.GetString("LoginError") + "Tim Usser");
         USUsers Item = new USUsers();
         try
         {
             Item = USUsersService.CheckLogin(model.UserName, model.Password);
             if (Item == null)
             {
                 TempData["MessageError"] = "Tài khoản hoặc mật khẩu không chính xác";
             }
             else
             {
                 HttpContext.Session.SetString("Login", JsonConvert.SerializeObject(Item));
                 return(RedirectToAction("Index"));
             }
         }
         catch (Exception e) {
             HttpContext.Session.SetString("LoginError", HttpContext.Session.GetString("LoginError") + e.Message);
         }
     }
     return(View(model));
 }
コード例 #19
0
ファイル: AccountSeeder.cs プロジェクト: jmibarrad/Sales
        public void Seed()
        {
            ICrypter encrypter = new Hasher();
            var      account   = new AccountLogin
            {
                Archived        = false,
                Email           = "*****@*****.**",
                Name            = "Jose Mario Ibarra",
                Password        = encrypter.Encrypt("password"),
                Role            = "admin",
                AccountMessages = new List <Messages>
                {
                    new Messages
                    {
                        Email   = "*****@*****.**",
                        Name    = "Jose Ibarra",
                        Message = "Queria consultar donde estan ubicados? Gracias",
                        Subject = "Importante"
                    }
                },
                UserInfo = new UserData()
            };

            _session.Save(account);
            _session.Flush();
            _session.Clear();
        }
コード例 #20
0
ファイル: AccountController.cs プロジェクト: LeTrongTuTai/MVC
        public JsonResult Login(string userName, string passWord)
        {
            Session[CommonConstants.AccountSession] = null;
            var result = _userDao.Login(userName, Encryptor.MD5Hash(passWord));

            if (result != 1)
            {
                return(Json(new
                {
                    status = false,
                    message = "Đăng nhập không đúng."
                }));
            }
            var user           = _userDao.GetByUserName(userName);
            var accountSession = new AccountLogin();

            accountSession.UserName = user.UserName;
            accountSession.UserID   = user.ID;
            accountSession.Name     = user.Name;
            accountSession.Email    = user.Email;
            accountSession.Phone    = user.Phone;
            accountSession.Address  = user.Address;
            Session.Add(CommonConstants.AccountSession, accountSession);
            return(Json(new
            {
                status = true
            }));
        }
コード例 #21
0
        public ActionResult Login(AccountLogin model)
        {
            User user = new User()
            {
                Username = model.UsernameOrEmail,
                Email    = model.UsernameOrEmail,
                Password = model.Password
            };

            var loginResult = _userRegistrationService.ValidateUser(model.UsernameOrEmail, model.Password);

            switch (loginResult)
            {
            case UserLoginResults.Successful:
            {
                // sign in user
                // TODO add remember me
                _authenticationService.SignIn(user, true);

                // TODO save login activity log

                // TODO redirect to return url

                return(RedirectToAction("Index", "Home"));
            }

                // TODO check other login results for login errors
            }

            return(View(model));
        }
コード例 #22
0
        public async Task <string> SignUp(AccountLogin accountLogin)
        {
            try
            {
                accountLogin.CreatedOn      = DateTime.Now;
                accountLogin.UpdatedOn      = DateTime.Now;
                accountLogin.User           = new User();
                accountLogin.User.IsActive  = true;
                accountLogin.User.CreateDon = DateTime.Now;
                var Role = await _context.Roles.FindAsync(Convert.ToInt64(1));

                accountLogin.User.Role = Role;
                _context.AccountLogins.Update(accountLogin);
                var result = await _context.SaveChangesAsync();

                string token = null;
                if (result > 0)
                {
                    token = GenerateToken(accountLogin.User.Id);
                }
                return(token);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
        }
コード例 #23
0
        public async Task <IActionResult> Login(AccountLogin userInput, string returnUrl)
        {
            if (!ModelState.IsValid)
            {
                return(View(userInput));
            }


            var  userName = userInput.Email; // Username or Email field in form.
            User user;

            // If form has '@' it is an email otherwise it is a username.
            // allows the user to login using either their email or username
            if (userName.IndexOf('@') > -1)
            {
                user = await _userManager.FindByEmailAsync(userName);

                if (user != null)
                {
                    userName = user.UserName;
                }
            }

            var result = await _signInManager.PasswordSignInAsync(userName, userInput.Password, userInput.RememberMe, lockoutOnFailure : false);

            if (result.Succeeded)
            {
                return(RedirectToReturn(returnUrl));
            }
            else
            {
                ModelState.AddModelError("", "Invalid UserName or Password");
                return(View());
            }
        }
コード例 #24
0
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new AccountDao();
         int result = dao.login(model.UserName, model.Passwork);
         if (result == 1)
         {
             var userSession = new AccountLogin();
             var user        = dao.GetbyId(model.UserName);
             userSession.AccountName = user.Username;
             userSession.AccountId   = user.ID;
             Session.Add(CommonConstanr.USER_SESSION, userSession);
             Session.Add("Username", user.Username);
             Session.Add("UserID", user.ID);
             Session.Add("Fullname", user.Fullname);
             Session.Add("UserLogin", user);
             return(RedirectToAction("Index", "Account"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "Tài khoản không tồn tại!");
         }
         else if (result == 2)
         {
             ModelState.AddModelError("", "Tài khoản bị khóa");
         }
         else
         {
             ModelState.AddModelError("", "Mật khẩu không đúng");
         }
     }
     return(View("Index"));
 }
コード例 #25
0
        public async Task <IActionResult> Login(AccountLogin model)
        {
            var result = await LoginUser(model);

            Account account = null;

            if (result.data == null || result.error != null)
            {
                return(View());
            }
            if (result.data != null)
            {
                account = result.data;
            }
            if (!isValidAccount(account))
            {
                return(View());
            }

            List <Claim> claims = new List <Claim>();

            claims.Add(new Claim("PersonId", account.PersonId));
            claims.Add(new Claim("Email", account.Email));
            claims.Add(new Claim("ProjectId", account.ProjectId.ToString()));
            if (!string.IsNullOrWhiteSpace(account.DisplayName))
            {
                claims.Add(new Claim("DisplayName", account.DisplayName));
            }
            if (!string.IsNullOrWhiteSpace(account.Avatar))
            {
                claims.Add(new Claim("Avatar", account.Avatar));
            }
            if (!string.IsNullOrWhiteSpace(account.WorkAs))
            {
                claims.Add(new Claim("WorkAs", account.WorkAs));
            }
            if (!string.IsNullOrWhiteSpace(account.Role))
            {
                claims.Add(new Claim(ClaimTypes.Role, account.Role));
            }
            else
            {
                claims.Add(new Claim(ClaimTypes.Role, "guest"));
            }
            if (account.Scopes.Any())
            {
                claims.Add(new Claim("Scopes", String.Join(",", account.Scopes)));
            }
            var userIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);

            ClaimsPrincipal principal      = new ClaimsPrincipal(userIdentity);
            var             authProperties = new AuthenticationProperties
            {
                IsPersistent = true
            };
            await HttpContext.SignInAsync(principal, authProperties);

            return(RedirectToAction("Index", "Home"));
        }
コード例 #26
0
        public async Task HandleAsync(UserSignuped message)
        {
            var accountLogin = AccountLogin.CreateAndInitializeAccount(message.Username);

            _context.AccountLogins.Add(accountLogin);

            await _context.Save();
        }
コード例 #27
0
        public frmNhanVien(AccountLogin transmission)
        {
            InitializeComponent();
            stateFirst();
            LoadDataNV();

            account = transmission;
        }
コード例 #28
0
        public frmInforMatHang(MatHang transmission, AccountLogin accountLogin)
        {
            InitializeComponent();

            XeDien  = transmission;
            account = accountLogin;

            loadInfo();
        }
コード例 #29
0
        public frmAccountInformation(AccountLogin accountLogin)
        {
            InitializeComponent();

            account = accountLogin;

            showInforAccountIsActive();
            TextBoxState1();
        }
コード例 #30
0
        public frmDSChiTietHangHoa(AccountLogin accountLogin)
        {
            InitializeComponent();

            account = accountLogin;

            loadData();
            setEnableButton1();
            setEnableTextBox1();
        }
コード例 #31
0
ファイル: LoginController.cs プロジェクト: geji5239/Sox-GNN
        public ActionResult Login(AccountLogin model, string returnUrl)
        {
            if (ModelState.IsValid)
            {
                string userName = model.Username;

                string password = model.Password;

                //var user = db.User.Where(u => u.Email == email).SingleOrDefault();

                //string salt = user.salt;

                //bool userValid = passwordManager.IsPasswordValid(password, salt, user.Password);

                bool userValid = true;

                if (userValid)
                {
                    FormsAuthentication.SetAuthCookie(userName, false);

                    if (returnUrl != null)
                        //return Redirect(returnUrl);
                        return RedirectToAction("Index", "Home");

                    return RedirectToAction("Index", "Home");

                }

                else
                {
                    ModelState.AddModelError("", "The username and password provided does not match.");
                }
            }

            else
            {
                ModelState.AddModelError("", "The username or password provided is not valid.");
            }

            return View(model);
        }