Inheritance: System.Web.UI.Page
Exemple #1
0
        private void Button1_Click(object sender, EventArgs e)
        {
            AdminLogin newMenu = new AdminLogin();

            this.Hide();
            newMenu.ShowDialog();
        }
        public IHttpActionResult Postadmin(AdminLogin admin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.AdminLogins.Add(admin);

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateException)
            {
                if (adminExists(admin.Username))
                {
                    return(Conflict());
                }
                else
                {
                    throw;
                }
            }

            return(CreatedAtRoute("DefaultApi", new { Username = admin.Username }, admin));
        }
        private void btn_AdminLogin_Click(object sender, RoutedEventArgs e)
        {
            AdminLogin adminLogin = new AdminLogin();

            adminLogin.Show();
            this.Close();
        }
Exemple #4
0
 public ActionResult AdminLogin(AdminLoginModel model)
 {
     if (ModelState.IsValid) //kiểm tra form rỗng
     {
         var dao    = new AdminDao();
         var result = dao.AdminLogin(model.TenDN, Encryptor.MD5Hash(model.MatKhau));
         if (result == 1)
         {
             var admin        = dao.GetByNameADMIN(model.TenDN);
             var adminSession = new AdminLogin();
             adminSession.TenDN   = admin.TenDN;
             adminSession.MaADMIN = admin.MaADMIN;
             Session.Add(CommonConstants.SESSION_ADMIN, adminSession);
             return(Redirect("/thong-tin-admin"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "Tên đăng nhập không đúng. Vui lòng kiểm tra lại!");
         }
         else
         {
             ModelState.AddModelError("", "Mật khẩu không chính xác. Vui lòng nhập lại!");
         }
     }
     return(View("AdminLoginView"));
 }
Exemple #5
0
 // GET: SignIn
 public ActionResult SignIn(string EmailId, string Password)
 {
     try
     {
         AdminLogin model   = new AdminLogin();
         SignInDal  objUser = new SignInDal();
         model.Username = EmailId;
         model.Password = Password;
         string response = objUser.checklogin(model);
         if (response == "success")
         {
             Session["Username"] = EmailId;
             return(RedirectToAction("Index", "Dashboard"));
         }
         else if (response == "False")
         {
             ViewBag.LoginError = "Invalid credentials, Please try again!";
             return(View());
         }
         else
         {
             ViewBag.LoginError = "Please fill all the fields";
             return(View());
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
Exemple #6
0
        public ActionResult ChangePassword(ChangePassword cp, AdminLogin al, Registration r)
        {
            if (ModelState.IsValid)
            {
                string username = Session["UserName"].ToString();
                al = db.AdminLogins.Where(a => a.UserName == username && a.Password == cp.OldPassword).FirstOrDefault();
                if (al != null)
                {
                    al.Password        = cp.Password;
                    al.ConfirmPassword = cp.ConfirmPassword;
                    db.SaveChanges();
                    return(RedirectToAction("Login", "Leads"));
                }

                else
                {
                    r = db.Registrations.Where(a => a.UserName == username && a.Password == cp.Password).FirstOrDefault();
                    if (r != null)
                    {
                        r.Password        = cp.Password;
                        r.ConfirmPassword = cp.ConfirmPassword;
                        db.SaveChanges();
                        return(RedirectToAction("Login", "Leads"));
                    }
                    else
                    {
                        ViewBag.Message = "Sorry! Invalid Old Password!";
                    }
                }
            }
            return(View());
        }
Exemple #7
0
        internal string checklogin(AdminLogin model1)
        {
            try
            {
                GTLOANEntities dbContext = new GTLOANEntities();
                if (model1.Username != "" && model1.Password != "")
                {
                    var loginresult = dbContext.AdminLogins.Where(s => s.Username == model1.Username && s.Password == model1.Password).FirstOrDefault();
                    if (loginresult != null)
                    {
                        return("success");
                    }
                    else
                    {
                        return("False");
                    }
                }
                else
                {
                    return("empty");
                }
            }
            catch (Exception)
            {
                return("False");

                throw;
            }
        }
Exemple #8
0
        public ActionResult Index(AdminLogin creds)
        {
            Admin adminModel = new Admin();
            var   emailLogin = adminLogin.Admins.ToList();
            var   emailmatch = emailLogin.Where(un => un.Admin_Login.Trim() == creds.UserName);

            foreach (Admin item in emailmatch)
            {
                adminModel = item;
            }
            if (!ModelState.IsValid)
            {
#if DEBUG
                var errors = ModelState.Where(ms => ms.Value.Errors.Count > 0).ToArray();
#endif
                return(View(creds));
            }
            if (BCrypt.Net.BCrypt.Verify(creds.Secret, emailmatch.Single().Secret))
            {
                var CLViewModel = new ConfigureLoginViewModel()
                {
                    Login        = creds,
                    LoginDbModel = adminModel
                };
                return(View("Configure", CLViewModel));
            }
            return(View());
        }
Exemple #9
0
        private void signInButton_Click(object sender, EventArgs e)
        {
            AdminLogin aAdminLogin = new AdminLogin();

            aAdminLogin.Username = userNameTextBox.Text;
            aAdminLogin.Password = passwordTextBox.Text;

            if (userNameTextBox.Text == "" || passwordTextBox.Text == "")
            {
                MessageBox.Show("Please fill up required the field");
            }
            else
            {
                LoginManager aLoginManager   = new LoginManager();
                bool         loginPermission = aLoginManager.GivePermitToLogin(aAdminLogin);
                if (loginPermission)
                {
                    Hide();
                    AdminUI aAdminUi = new AdminUI();
                    aAdminUi.Show();
                }
                else
                {
                    MessageBox.Show("Invalid username or password");
                }
            }
        }
        public ActionResult AdminSectionLogIn(AdminLogin adminlogin)
        {
            string message = "";

            ViewBag.Message = message;
            using (MortgageDbEntities dc = new MortgageDbEntities())
            {
                var v = dc.AdminDetails.Where(a => a.EmailId == adminlogin.EmailId).FirstOrDefault();
                if (v != null)
                {
                    if ((string.Compare((adminlogin.Password), v.Password) == 0) && (string.Compare((adminlogin.Role), v.Role) == 0))
                    {
                        if (v.Role == "Manager")
                        {
                            Session["id"] = v.Id;
                            return(RedirectToAction("index", "Home"));
                        }
                        else if (v.Role == "Inspector")
                        {
                        }
                    }
                    else
                    {
                        message = "Invalid Credential provided";
                    }
                }
                else
                {
                    message = "Invalid Credential provided";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
        private void Logout_Click(object sender, RoutedEventArgs e)
        {
            var window = new AdminLogin();

            window.Show();
            this.Close();
        }
        public IActionResult Index(Login ob)
        {
            AdminLogin obj = _db.AdminLogin.Find(ob.ID);

            if (obj != null)
            {
                byte[] salt = obj.Salt;
                if (obj.Password == ComputeHMAC_SHA256(ob.Password, salt))
                {
                    ViewBag.WrongIdPass = false;
                    ViewBag.Admin       = true;
                    HttpContext.Session.SetString("id", ob.ID.ToString());
                    HttpContext.Session.SetString("user", "Admin");
                    return(RedirectToAction("Index", "Admin"));
                }
            }
            Login obj2 = _db.Login.Find(ob.ID);

            if (obj2 != null)
            {
                byte[] salt = obj2.Salt;
                if (obj2.Password == ComputeHMAC_SHA256(ob.Password, salt))
                {
                    ViewBag.WrongIdPass = false;
                    ViewBag.Admin       = false;
                    HttpContext.Session.SetString("id", ob.ID.ToString());
                    HttpContext.Session.SetString("user", "Employee");
                    return(RedirectToAction("Index", "Employee", new { id = ob.ID }));
                }
            }
            ViewBag.WrongIdPass = true;
            return(View("Index"));
        }
Exemple #13
0
 public ActionResult Login([Bind(Include = "Name,Password,RememberMe")] AdminLogin login, string returnUrl)
 {
     if (ModelState.IsValid)
     {
         string hahsedpassword = HashHelper.Encrypt(login.Password);
         var    registered     = db.CP_User.Where(s => s.Name == login.Name && s.Password == hahsedpassword).FirstOrDefault();
         if (registered == null)
         {
             ViewBag.ModelErrors = "غير مسجل او التحقق من البيانات";
             return(View(login));
         }
         Session["UserName"] = registered.Name;
         Session["UserId"]   = registered.ID;
         Session["CourseId"] = registered.CoursePrivilege;
         if (registered.CoursePrivilege == null)
         {
             Session["UserType"] = Enum.GetName(typeof(Role), 2);
         }
         else
         {
             dynamic course = SystemHelper.GetCourseObject((int)registered.CoursePrivilege);
             Session["UserType"] = course.GetType().Name.ToString();
         }
         if (login.RememberMe)
         {
             HttpCookie UserCookie = new HttpCookie("c_user");
             UserCookie.Values["u_id"] = HashHelper.Encrypt(registered.ID.ToString());
             UserCookie.Values["u_pa"] = HashHelper.Encrypt(registered.Password);
             UserCookie.Expires        = DateTime.Now.AddYears(1);
             Response.Cookies.Add(UserCookie);
         }
         return(RedirectToLocal(returnUrl));
     }
     return(View(login));
 }
Exemple #14
0
        //async arbetar så att det inte laggar imellan medans sökningen sker, tar emot användarnamn och lösenord från view
        public async Task <IActionResult> IndexAsync(AdminLogin userinfo, string returnur1 = null)
        {
            //Hämta värden från en annan metod, tar in användarnamnet
            bool userOk = CheckUser(userinfo);

            //Om returnerad värde är true, körs koden
            if (userOk == true)
            {
                //Begär identitet/Tillåtelse för att få tillgång till webbplats, Säkerthet
                var identity = new ClaimsIdentity(CookieAuthenticationDefaults.AuthenticationScheme);
                identity.AddClaim(new Claim(ClaimTypes.Name, userinfo.användarnamn));

                await HttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(identity));

                if (returnur1 != null)
                {
                    return(Redirect(returnur1));
                }
                else
                {
                    //Om inloggning OK skickas man till adminsidan
                    return(RedirectToAction("Admin", "Burger"));
                }
            }
            else
            {
                //om inte OK visas ErrorMessage
                ViewBag.ErrorMessage = "Inloggning inte godkänt!";
            }
            return(View());
        }
 public ActionResult AdminLogin(AdminLogin login)
 {
     try
     {
         var result = this.adminBL.AdminLogin(login);
         if (result != null)
         {
             string token = GenrateJWTToken(result.Email, (long)result.AdminId);
             return(this.Ok(new
             {
                 success = true,
                 Message = "Admin login successfully",
                 Data = result,
                 Token = token
             }));
         }
         else
         {
             return(this.NotFound(new { success = false, Message = "Admin login unsuccessfully" }));
         }
     }
     catch (Exception e)
     {
         return(this.BadRequest(new { success = false, Message = e.Message }));
     }
 }
Exemple #16
0
            public void GivenLogIntoDashBoard_CreateANewLead()
            {
                Log.WriteStringLine();
                Log.Write("There was a problem in shifting bytes left!");
                Log.WriteLine();
                Log.WriteFormat("Test args {0} and {1}", "#first#", "#second#");
                Log.WriteLineFormat("Test args {0} and {1}", "#first#", "#second#");

                Log.Write(" The Start Time");

                Log log = new Log(driver);

                driver    = log.driver;
                driver    = Driver.Initialize(ConfigurationManager.AppSettings["BrowserIEName"]);
                url       = ConfigurationManager.AppSettings["EnvironmentUrl"];
                login     = new AdminLogin(driver);
                dashBoard = new DashBoard(driver);
                login.NavigateToLoginPage(driver, url);
                login.NavigateToDashBoard(driver, ConfigurationManager.AppSettings["BankerUserName"], ConfigurationManager.AppSettings["BankerPassword"]);
                var watch = System.Diagnostics.Stopwatch.StartNew();

                dashBoard.NavigateToClient(driver);
                watch.Stop();
                var elapsedMs = watch.ElapsedMilliseconds;

                Log.Write(" The elapsed time " + elapsedMs.ToString());
            }
        public ActionResult Login(LoginModel model)
        {
            if (ModelState.IsValid)
            {
                var dao    = new AdminAccountDAO();
                var result = dao.Login(model.Username, Encryptor.MD5Hash(model.Password));
                if (result == 1)
                {
                    var user        = dao.GetAdminByUserName(model.Username);
                    var userSession = new AdminLogin();
                    userSession.AdminName = user.userName;

                    userSession.AdminID = user.id;
                    Session.Add(Common.CommonConstants.USER_SESSION, userSession);
                    return(RedirectToAction("Index", "Home"));
                }
                else if (result == 0)
                {
                    ModelState.AddModelError("", "Tài khoản không tồn tại");
                }
                else if (result == -1)
                {
                    ModelState.AddModelError("", "Tài khoản đang bị khóa");
                }
                else
                {
                    ModelState.AddModelError("", "Sai mật khẩu");
                }
            }
            else
            {
            }
            return(View("Index"));
        }
        public async Task <IActionResult> Edit(AdminLogin admin)
        {
            var oldAdmin = await iadminLoginResponsitory.GetById(admin.Id);

            if (admin.Password != null && admin.Password != "")
            {
                admin.Password = BCrypt.Net.BCrypt.HashPassword(admin.Password);
            }
            if ((admin.Password == "" || admin.Password == null) && oldAdmin.Password != "")
            {
                admin.Password = oldAdmin.Password;
            }
            admin.UserType = oldAdmin.UserType;
            var checkUserName = iadminLoginResponsitory.GetAllWithoutTracking().Where(p => p.UserName.Equals(admin.UserName) && p.Id != admin.Id).Count();

            if (checkUserName > 0)
            {
                ModelState.AddModelError("username", "Username is used.");
                return(View("index", admin));
            }
            if (ModelState.IsValid)
            {
                await iadminLoginResponsitory.Update(admin.Id, admin);

                return(RedirectToAction("index", "policiesonemployees"));
            }
            return(View("index", admin));
        }
Exemple #19
0
        public AdminLogin LoginIn(AdminLogin admin)
        {
            DataSet    ds       = new DataSet();
            AdminLogin objLogin = new AdminLogin();

            try
            {
                SqlParameter[] param = new SqlParameter[2];
                param[0] = new SqlParameter("@username", admin.userName);
                param[1] = new SqlParameter("@password", admin.password);
                ds       = DBConnectionSQL.gettable("getLoginAdmin", param);
                foreach (DataRow dr in ds.Tables[0].Rows)
                {
                    objLogin.userName     = dr["user_name"].ToString();
                    objLogin.userFullName = dr["full_name"].ToString();
                    objLogin.isLogin      = true;
                }
            }
            catch (Exception)
            {
                objLogin.isLogin = false;
                throw;
            }
            return(objLogin);
        }
Exemple #20
0
        public ActionResult Login(AdminLogin adminLogin)
        {
            string message = "";

            ViewBag.Message = message;
            using (WEBUIEntities5 dc = new WEBUIEntities5())
            {
                var v = dc.AdminLogins.Where(a => a.UserName == adminLogin.UserName).FirstOrDefault();
                if (v != null)
                {
                    if (string.Compare((adminLogin.Password), v.Password) == 0)
                    {
                        return(RedirectToAction("index", "Home"));
                    }
                    else
                    {
                        message = "Invalid Credential provided";
                    }
                }
                else
                {
                    message = "Invalid Credential provided";
                }
            }
            ViewBag.Message = message;
            return(View());
        }
        public ActionResult Verify(AdminLogin log)
        {
            //working of the database connectivty so thus connection can be work and verify the record after matching

            connectionString();
            con.Open();
            cmd.Connection = con;

            cmd.CommandText = "select * from AdminLogin where MUserName='******' and MPassword='******'";

            dr = cmd.ExecuteReader();

            if (dr.Read())
            {
                con.Close();
                // if the user namre and passworrd is true then the next page adminzone will be open other wise the it will open the invalid page will be open
                return(View("AdminZone"));
            }
            else
            {
                // it will transfer to the invalid page
                con.Close();
                return(View("Invalid"));
            }
        }
Exemple #22
0
    protected void Button1_Click(object sender, EventArgs e)
    {
        msg.Visible = true;
        try
        {
            AdminLogin al = new AdminLogin();
            db.dt = al.CheckAdmin(username.Text, password.Text);

            if (db.dt.Rows.Count > 0)
            {
                Session["usernames"] = username.Text;
                Session["password"]  = password.Text;
                Session["roles"]     = db.dt.Rows[0]["role"].ToString();
                Response.Redirect("index.aspx");
            }
            else
            {
                msg.Text      = "invalid username or password";
                msg.ForeColor = Color.Red;
            }
        }
        catch (Exception ex)
        {
            ltrmsg.Text = ex.Message;
        }
    }
Exemple #23
0
        public ActionResult CheckAuthenticate(AdminLogin adminLogin)
        {
            var result = apiCaller.Call <LoginRequest, LoginResponse>(Model.Web.CPanelAPIControllers.CPAuthentication, "Login", HttpMethod.Post, new LoginRequest()
            {
                UserName = adminLogin.UserName,
                Password = adminLogin.Password
            });

            if (result.Status == Model.ResponseStatus.Success)
            {
                return(RedirectToAction("Home", "Home", new { area = "" }));
            }
            else
            {
                AdminLogin adminLoginResponse = new AdminLogin();
                adminLoginResponse.Status = result.Status;
                if (result.EndUserMessage != null)
                {
                    adminLoginResponse.EndUserMessage = result.EndUserMessage;
                }
                else
                {
                    adminLoginResponse.EndUserMessage = "Api Connection Problem!";
                }
                return(View("Login", adminLoginResponse));
            }
        }
 public ActionResult Login(LoginModel model)
 {
     if (ModelState.IsValid)
     {
         var dao    = new AdminDAO();
         var result = dao.Login(model.UserName, Encryptor.MD5Hash(model.Password));
         if (result == 1)
         {
             var admin        = dao.GetByUserName(model.UserName);
             var AdminSession = new AdminLogin();
             AdminSession.UserName = admin.UserName;
             Session.Add(Constant.ADMIN_SESSION, AdminSession);
             return(RedirectToAction("Index", "Product"));
         }
         else if (result == 0)
         {
             ModelState.AddModelError("", "The requested user could not be found.");
         }
         else if (result == 2)
         {
             ModelState.AddModelError("", "Password incorrect");
         }
         else
         {
             ModelState.AddModelError("", "E-mail incorrect");
         }
     }
     return(View("Index"));
 }
        public IHttpActionResult Putadmin(string Username, AdminLogin admin)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Username != admin.Username)
            {
                return(BadRequest());
            }

            db.Entry(admin).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!adminExists(Username))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private void Border_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
        {
            Border border = sender as Border;

            if (border != null)
            {
                switch (border.Name)
                {
                case "售票系统":
                    MainWindow mainWindow = new MainWindow();
                    this.Close();
                    mainWindow.Show();
                    break;

                case "管理系统":
                    AdminLogin adminLogin = new AdminLogin();
                    this.Close();
                    adminLogin.Show();
                    break;

                case "进出站系统":
                    InAndOut inandout = new InAndOut();
                    this.Close();
                    inandout.Show();
                    break;

                default:
                    break;
                }
            }
        }
        public ActionResult Ayarlar(FormCollection form)
        {
            string kullaniciadi = form["kullaniciadi"].ToString();
            string sifre        = form["sifre"].ToString();
            string sifre2       = form["sifre2"].ToString();

            if (string.Equals(sifre, sifre2))
            {
                using (ModelDB db = new ModelDB())
                {
                    AdminLogin al = db.AdminLogin.SingleOrDefault();
                    al.kullaniciadi = kullaniciadi;
                    al.sifre        = sifre;

                    int sonuc = db.SaveChanges();
                    if (sonuc > 0)
                    {
                        TempData["Result"] = "Kaydedildi";
                        TempData["Status"] = "success";
                    }
                }
            }
            else
            {
                TempData["Result"] = "Şifreler birbiri ile aynı olmak zorundadır.";
                TempData["Status"] = "danger";
            }
            using (ModelDB db = new ModelDB())
            {
                AllTables2 at = new AllTables2();
                at.admin = db.AdminLogin.SingleOrDefault();

                return(View(at));
            }
        }
        public IActionResult LoginNow(AdminLogin model)
        {
            var admin = db.AdminLogin.Where(x => x.UserName.Trim() == model.UserName.Trim() && x.Password == model.Password).FirstOrDefault();

            try
            {
                if (admin != null)
                {
                    admin.Role = db.Role.Where(x => x.Id == admin.RoleId).FirstOrDefault();
                    _          = CreateAuthenticationTicket(admin);
                    // Show Success Message -"Welcome!"
                    return(RedirectToAction(nameof(ProfileController.CreateEditProfile), "Profile"));
                }
                else
                {
                    //  Show Error Message- "Invalid Credentials."
                    return(View("Index", model));
                }
            }
            catch (Exception ex)
            {
                //Show Error Message- ex.Message
                return(View("Index", model));
            }
        }
Exemple #29
0
        public async Task <bool> Login(AdminLogin model)
        {
            if (model == null)
            {
                return(false);
            }

            await this.AgregarToken().ConfigureAwait(false);

            var loginJson = new StringContent(JsonSerializer.Serialize(model), Encoding.UTF8, "application/json");
            var response  = await this._httpClient.PostAsync($"login", loginJson).ConfigureAwait(false);

            var loginResult = await JsonSerializer.DeserializeAsync <LoginResult>(
                await response.Content.ReadAsStreamAsync().ConfigureAwait(false),
                new JsonSerializerOptions()
            {
                PropertyNameCaseInsensitive = true
            }).ConfigureAwait(false);

            loginJson.Dispose();

            if (!response.IsSuccessStatusCode)
            {
                return(false);
            }

            await this._localStorage.SetItemAsync("authToken", loginResult.Token).ConfigureAwait(false);

            ((ApiAuthenticationStateProvider)this._authenticationStateProvider).MarkUserAsAuthenticated(model.Usuario);
            this._httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("bearer", loginResult.Token);

            return(true);
        }
        public string Login([FromBody] AdminLogin adminLogin)
        {
            string message = "";

            using (MyDbEntities db = new MyDbEntities())
            {
                var user = db.Admins.Where(a => a.Email == adminLogin.Email && a.IsEmailVerified == true).FirstOrDefault();
                if (user != null)
                {
                    if (string.Compare(Crypto.Hash(adminLogin.Password), user.Password) == 0)
                    {
                        if (user.IsEmailVerified == true)
                        {
                            message = "Success";
                        }
                        else
                        {
                            message = "Invalid credential Provided";
                        }
                    }
                    else
                    {
                        message = "Invalid credential Provided";
                    }
                }
                else
                {
                    message = "Invalid credential Provided";
                }
            }
            return(message);
        }