Exemplo n.º 1
0
 //login
 public void logins()
 {
     if (db.f_login(txtuser.Text, encryptype.psEncrypt(txtpass.Text)) == true)
     {
         setcookie();
     }
     else
     {
         promt.Text = "<div class='error'>Invalide Username!!!</div>";
     }
 }
Exemplo n.º 2
0
        public ActionResult Login(TccgLogin login)
        {
            var    dbcontext = new TCCGDataContext();
            var    security  = new clssecurity();
            bool   logres;
            bool   loginstatus = true;
            string strerrormsg = string.Empty;

            if (string.IsNullOrEmpty(login.uname) || string.IsNullOrEmpty(login.upass))
            {
                @ViewBag.Title = "Admin | Login";
                return(View());
            }


            logres = dbcontext.IsLogin(login.uname.ToUpper(), security.psEncrypt(login.upass)) == true ? true : false;


            if (logres)
            {
                TCCG_USER up = dbcontext.TCCG_USERs.First(aa => aa.username == login.uname);

                if (up.userstatus != true)
                {
                    strerrormsg += "Sorry your account is inactive!";
                    loginstatus  = false;
                }


                if (!loginstatus)
                {
                    ViewBag.error  = strerrormsg;
                    @ViewBag.Title = "TCCG | Login";
                }
                else
                {
                    Session["_cid"]  = up.username;
                    Session["_crol"] = up.usergroup;
                    Session.Timeout  = 30;
                }
            }


            if (!loginstatus)
            {
                return(View());
            }
            else
            {
                this.SetPmsCookie(login.RememberMe, login.uname.ToUpper(), login.upass);

                return(RedirectToAction("Index"));
            }
        }
Exemplo n.º 3
0
        public void SetPmsCookie(bool isremember, string username, string password)
        {
            clssecurity sec = new clssecurity();

            if (isremember)
            {
                HttpCookie cookie = Request.Cookies["tccg"];
                if (cookie == null)
                {
                    cookie           = new HttpCookie("tccg");
                    cookie["_00un"]  = username;
                    cookie["_00up"]  = sec.psEncrypt(password);
                    cookie["_00rmd"] = isremember.ToString();
                    Response.Cookies.Add(cookie);
                }
            }
        }
Exemplo n.º 4
0
        public JsonResult login(TccgLogin login)
        {
            try
            {
                string msg      = string.Empty;
                var    security = new clssecurity();
                bool?  logres;
                bool   isresult = false;
                logres = dbcontext.IsLogin(login.uname, security.psEncrypt(login.upass));


                if (logres == true)
                {
                    TCCG_USER up = dbcontext.TCCG_USERs.First(aa => aa.username == login.uname);

                    if (up.userstatus != true)
                    {
                        msg = "Your account is not active, Please contact Administrator";
                    }
                    else
                    {
                        Session["_cid"]  = up.username;
                        Session["_crol"] = up.usergroup;
                        Session.Timeout  = 30;
                        this.SetPmsCookie(login.RememberMe, login.uname, login.upass);
                        isresult = true;
                    }
                }
                else
                {
                    msg = "Please Contact Administrator!";
                }

                return(Json(new { result = true, msg = msg, isresult = isresult }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = false, err = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 5
0
        public JsonResult CreateNewUser(UserSetup details)
        {
            try
            {
                clssecurity security = new clssecurity();

                string newpass    = security.psEncrypt(details.password);
                string str_result = string.Empty;
                if (dbcontext.SPROC_SAVE_USER(details.uname, newpass, details.fullname, details.designation,
                                              details.email, "SID002", true, DateTime.Now.Date, DateTime.Now.Date).ReturnValue.ToString() == "0")
                {
                    List <TCCG_USER_RIGHT> q_listdel = (from aa in dbcontext.TCCG_USER_RIGHTs
                                                        where aa.Username == details.uname
                                                        select aa).ToList();
                    if (q_listdel.Count != 0)
                    {
                        dbcontext.TCCG_USER_RIGHTs.DeleteAllOnSubmit(q_listdel);
                        dbcontext.SubmitChanges();
                    }

                    foreach (var row in details.accesslst)
                    {
                        if (row.ischeck)
                        {
                            str_result = dbcontext.SPROC_SAVE_USER_RIGHTS(row.menuid, details.uname, procedure.GetUsername()).ReturnValue.ToString();
                        }
                    }
                }

                return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                return(Json(new { result = false, err = ex.Message }, JsonRequestBehavior.AllowGet));
            }
        }
Exemplo n.º 6
0
 protected void Button1_Click(object sender, EventArgs e)
 {
     Label1.Text = classsecuryty.psEncrypt(TextBox1.Text);
 }
Exemplo n.º 7
0
        protected void btnsubmit_Click(object sender, EventArgs e)
        {
            HttpCookie cookie   = Request.Cookies["rowenref"];                           //declaration of cookie
            user       Usrs     = db.users.First(u => u.username == cookie["username"]); //retrieve uer id
            string     password = clssEncryptsecurity.psDescrypt(Usrs.password);         //show password


            string Id         = Request.QueryString["id"];
            string Profilepic = Usrs.Image.ToString();

            if (fileuserimage.PostedFile == null)
            {
                if (Profilepic == null)
                {
                    db.sp_UPDATE_tbl_userInfo(Convert.ToInt16(Usrs.id), cookie["username"], clssEncryptsecurity.psEncrypt(password), txtfname.Text, txtlname.Text, txtemail.Text, dropgender.Text, txtmname.Text, txtaddress.Text, null);
                    Label1.Text = "<div class='ok'>Update user info Successful</div>";
                    MultiView2.ActiveViewIndex = 0;
                }
                else
                {
                    db.sp_UPDATE_tbl_userInfo(Convert.ToInt16(Usrs.id), cookie["username"], clssEncryptsecurity.psEncrypt(password), txtfname.Text, txtlname.Text, txtemail.Text, dropgender.Text, txtmname.Text, txtaddress.Text, Usrs.Image);
                    Label1.Text = "<div class='ok'>Update user info Successful</div>";
                    MultiView2.ActiveViewIndex = 0;
                }
            }
            else
            {
                if (fileuserimage.PostedFile != null)
                {
                    string sub = string.Empty, imagePath = string.Empty, imgFilename = string.Empty;
                    // Check that there is a file
                    if (fileuserimage.PostedFile != null)
                    {
                        //Path to store uploaded files on server - make sure your paths are unique


                        string filePath  = "../profilepic/oreginal/" + txtusername.Text + ".jpg";
                        string thumbPath = "../profilepic/thumb/" + txtusername.Text + ".jpg";

                        // Check file size (mustn’t be 0)
                        HttpPostedFile myFile   = fileuserimage.PostedFile;
                        int            nFileLen = myFile.ContentLength;
                        if ((nFileLen > 0) && (System.IO.Path.GetExtension(myFile.FileName).ToLower() == ".jpg"))
                        {
                            // Read file into a data stream
                            byte[] myData = new Byte[nFileLen];
                            myFile.InputStream.Read(myData, 0, nFileLen);
                            myFile.InputStream.Dispose();

                            // Save the stream to disk as temporary file. make sure the path is unique!
                            System.IO.FileStream newFile = new System.IO.FileStream(Server.MapPath(filePath + "_temp.jpg"),
                                                                                    System.IO.FileMode.Create);

                            newFile.Write(myData, 0, myData.Length);

                            // run ALL the image optimisations you want here..... make sure your paths are unique
                            // you can use these booleans later if you need the results for your own labels or so.
                            // dont call the function after the file has been closed.
                            bool success = ResizeImageAndUpload(newFile, thumbPath, 300, 300);
                            success = ResizeImageAndUpload(newFile, filePath, 1200, 900);

                            // tidy up and delete the temp file.
                            newFile.Close();
                            System.IO.File.Delete(Server.MapPath(filePath + "_temp.jpg"));
                        }
                        imgFilename = Path.GetFileName(thumbPath);

                        Stream imgdatastream = fileuserimage.PostedFile.InputStream;
                        int    imgdatalen    = fileuserimage.PostedFile.ContentLength;
                        byte[] imgdata       = new byte[imgdatalen];
                        int    n             = imgdatastream.Read(imgdata, 0, imgdatalen);

                        db.sp_UPDATE_tbl_userInfo(Convert.ToInt16(Usrs.id), cookie["username"], clssEncryptsecurity.psEncrypt(password), txtfname.Text, txtlname.Text, txtemail.Text, dropgender.Text, txtmname.Text, txtaddress.Text, imgFilename);
                        Label1.Text = "<div class='ok'>Update user info Successful</div>";
                        MultiView2.ActiveViewIndex = 0;
                        Response.Redirect("account.aspx");
                    }
                }
            }
        }