Exemple #1
0
        private void UpdatePassword(string password, string email, string temp)
        {
            var user = _userService.GetUserByEmailAndTempPass(email, temp);

            if (user != null)
            {
                var enCrypt = _encryptor.Encrypt(password);

                user.password           = enCrypt;
                user.status             = 1;
                user.temporary_password = String.Empty;

                _insendluEntities.Entry(user).State = EntityState.Modified;
                int success = _insendluEntities.SaveChanges();

                if (success == 1)
                {
                    Session["passupdated"] = true;
                    Response.Redirect("index.aspx");
                }
            }
        }
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var username       = txtEmail.Value;
            var password       = txtPassword.Value;
            var decryDecrypted = _encryptor.Encrypt(password);

            var user = (from users in _insendluEntities.Users
                        where users.email == username
                        select users).Single();

            if (user != null)
            {
                if (user.password == decryDecrypted)
                {
                    Session["Username"] = user.name;
                    Session["ID"]       = user.id;
                    Session["image"]    = "assets/images/avatars/user.jpg";

                    if (user.user_type_id == 2)
                    {
                        Response.Redirect("~/UserPages/Index.aspx");
                    }
                    Response.Redirect("AdminPage.aspx");
                }
                else
                {
                    errorMessage.Text    = "Incorrect credentials, re-try again";
                    errorMessage.Visible = true;
                }
            }
            else
            {
                errorMessage.Text    = "No user found for that credentials, please try again later";
                errorMessage.Visible = true;
            }
        }
Exemple #3
0
        protected void btnLogin_Click(object sender, EventArgs e)
        {
            var email          = txtEmail.Value;
            var password       = txtPassword.Value;
            var decryDecrypted = _encryptor.Encrypt(password);

            var user = (from users in _insendluEntities.Users
                        where users.email == email
                        select users).SingleOrDefault();

            if (user != null)
            {
                Session["UserType"] = user.user_type_id;

                if (user.status == 0)
                {
                    if (user.temporary_password == decryDecrypted)
                    {
                        Session["Username"] = user.name;
                        Session["ID"]       = user.id;

                        var userProf = (from prof in _insendluEntities.UserProfiles
                                        where prof.user_id == user.id
                                        select prof).FirstOrDefault();

                        if (userProf != null)
                        {
                            if (userProf.profile_pic != null)
                            {
                                Session["image"] = "data: Image/png;base64," + Convert.ToBase64String(userProf.profile_pic);
                            }
                            else
                            {
                                Session["image"] = "assets/images/avatars/user.jpg";
                            }
                        }

                        Response.Redirect("~/Dashboard.aspx");
                    }
                }
                else if (user.password == decryDecrypted)
                {
                    Session["Username"] = user.name;
                    Session["ID"]       = user.id;

                    var userProf = (from prof in _insendluEntities.UserProfiles
                                    where prof.user_id == user.id
                                    select prof).FirstOrDefault();

                    if (userProf != null)
                    {
                        if (userProf.profile_pic != null)
                        {
                            Session["image"] = "data: Image/png;base64," + Convert.ToBase64String(userProf.profile_pic);
                        }
                        else
                        {
                            Session["image"] = "assets/images/avatars/user.jpg";
                        }
                    }

                    Response.Redirect("~/Dashboard.aspx");
                }
                else
                {
                    errorMessage.Text      = "Incorrect credentials, re-try again";
                    errorMessage.BackColor = Color.IndianRed;
                    errorMessage.Visible   = true;
                }
            }
            else
            {
                Page.ClientScript.RegisterClientScriptBlock(GetType(), "alert", "alert('No user found with those credentials, please try again or contact Admin')", true);
                errorMessage.Text      = "No user found with those credentials, please try again later";
                errorMessage.BackColor = Color.IndianRed;
                errorMessage.Visible   = true;
            }
        }