Ejemplo n.º 1
0
 public void LoginWithGooglePlus()
 {
     GoogleConnect.ClientId     = "508536128158-3v4078lig5vbt6j727okq6ie2b45tg0n.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "UQlFGFFRQq_Ztfw4FbqzZh_D";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
Ejemplo n.º 2
0
 public ActionResult LoginWithGooglePlusConfirmed()
 {
     if (!string.IsNullOrEmpty(Request.QueryString["code"]))
     {
         string        code    = Request.QueryString["code"].ToString();
         string        json    = GoogleConnect.Fetch("me", code.ToString());
         GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
         //code for showing data on my page
         Session["usernameGO"] = profile.Id;
         Session["NameGO"]     = profile.Name;
         Session["Email"]      = profile.Email;
         Session["ImgGO"]      = profile.Picture;
         if (CheckFirstLogin(profile.Id) == true)
         {
             return(RedirectToAction("Registration", "User"));
         }
         else
         {
             AccountDAO dao = new AccountDAO();
             Session["ComNa"] = dao.GetCoByUsername(profile.Id);
             return(RedirectToAction("Manager", "Product"));
         }
     }
     if (Request.QueryString["error"] == "access_denied")
     {
         return(Content("access_denied"));
     }
     return(RedirectToAction("Index", "Home"));
 }
Ejemplo n.º 3
0
 public void LoginWithGooglePlus()
 {
     GoogleConnect.ClientId     = "988136019750-lrkpmiauffr8dlbjbqjjmh82aiti7iqs.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "aMCHg7U8aJhjcvH-A5LiQmvn";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
Ejemplo n.º 4
0
        public static void FinishSignIn()
        {
            HttpRequest Request = HttpContext.Current.Request;

            if (Request != null)
            {
                try {
                    string code = Request.QueryString["code"];
                    if (string.IsNullOrEmpty(code))
                    {
                        return;
                    }

                    GoogleConnect.ClientId     = ApiSettings.Default.GoogleClientId;
                    GoogleConnect.ClientSecret = ApiSettings.Default.GoogleClientSecret;

                    GoogleConnect googleConnect = new GoogleConnect(Request.Url.AbsoluteUri.Split('?')[0] + SocialSignIn.GoogleRedirectQuery);
                    string        json          = googleConnect.Fetch(code, "me");

                    GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
                    if (profile != null && profile.Emails.Count > 0)
                    {
                        foreach (Email email in profile.Emails)
                        {
                            string username = email.Value.Replace(email.Value.Substring(email.Value.IndexOf("@")), "").Replace(" ", "_") + "@Google"; // You can change this to be anything you want.

                            // From here you will need to create the user on your own database or use some method to store the user information
                        }
                    }
                }
                catch (Exception e) {
                    // Add your own code in here to capture the error and log it
                }
            }
        }
Ejemplo n.º 5
0
        public ActionResult LoginWithGooglePlusConfirmed()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string        code    = Request.QueryString["code"];
                string        json    = GoogleConnect.Fetch("me", code);
                GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);



                WebBanHang1.Models.Customers khachHang = new WebBanHang1.Models.Customers()
                {
                    CustomerName = profile.DisplayName,
                    Email        = profile.Emails.Find(email => email.Type == "account").Value,
                    MatKhau      = profile.Emails.Find(email => email.Type == "account").Value,
                    TenDN        = profile.Emails.Find(email => email.Type == "account").Value
                };


                if (db.TimKh(khachHang.TenDN, khachHang.MatKhau) != null)
                {
                    Session["customer"] = db.TimKh(khachHang.TenDN, khachHang.MatKhau);
                    return(Redirect(TempData["url"].ToString()));
                }
                db.Dangki_Facebook(khachHang);
                Session["customer"] = db.TimKh(khachHang.TenDN, khachHang.MatKhau);
            }
            if (Request.QueryString["error"] == "access_denied")
            {
                return(Content("access_denied"));
            }
            return(RedirectToAction("Index", "Trangchu"));
        }
 public void LoginWithGooglePlus()
 {
     GoogleConnect.ClientId     = "164802556545-rvmd1u9vu1es5ah51tvte7554t9kh4h6.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "ak0LpmTv8wZI3AVLnyI-1sg3";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
Ejemplo n.º 7
0
 public void LoginWithGooglePlus()
 {
     GoogleConnect.ClientId     = "708368987259-8dtilh79brr03nmuisao8p0atimr80ii.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "61Pg87LPaI0Mot5VTedVi02O";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
        public ActionResult LoginWithGooglePlusConfirmed()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string        code    = Request.QueryString["code"];
                string        json    = GoogleConnect.Fetch("me", code);
                GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);


                var cus = db.Customers.Find(profile.Id);
                if (cus != null)
                {
                    Session["khachhang"] = cus;
                    return(RedirectToAction("Index", "Home"));
                }
                Customer customer = new Customer()
                {
                    ID       = profile.Id,
                    FullName = profile.DisplayName,
                    Email    = profile.Emails.Find(email => email.Type == "account").Value
                };
                Session["khachhang"] = customer;
                db.Customers.Add(customer);
                db.SaveChanges();
            }
            if (Request.QueryString["error"] == "access_denied")
            {
                return(Content("access_denied"));
            }
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 9
0
 public void LoginWithGooglePlus()
 {
     GoogleConnect.ClientId     = "618863968324-4a64tsm3ehm6m86135hqpoq75umk1719.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "G7Zb7XHW-JUjVo6yaQ6USP6_";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
Ejemplo n.º 10
0
        //  EmailCode ab = new EmailCode();
        protected void Page_Load(object sender, EventArgs e)
        {
            GoogleConnect.ClientId     = "257048884331-7p8367n9n5n5ouq7rl4004uemt3bcnrv.apps.googleusercontent.com";
            GoogleConnect.ClientSecret = "wkijjMQTCQBfDjsSqS-FDnJG";

            GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];

            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string        code    = Request.QueryString["code"];
                string        json    = GoogleConnect.Fetch("me", code);
                GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
                lblId.Text            = profile.Id;
                lblNome.Text          = profile.DisplayName;
                lblEmail.Text         = profile.Emails.Find(email => email.Type == "account").Value;
                lblSexo.Text          = profile.Gender;
                lblTipo.Text          = profile.ObjectType;
                ProfileImage.ImageUrl = profile.Image.Url;
                pnlProfile.Visible    = true;
                btnLogin.Enabled      = false;
            }
            if (Request.QueryString["error"] == "access_denied")
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
            }
        }
Ejemplo n.º 11
0
        // END functions

        protected void Page_Load(object sender, EventArgs e)
        {
            GoogleConnect.ClientId     = "61887612183-e7q4pgf205etss30qa63k366gdvrefbu.apps.googleusercontent.com";
            GoogleConnect.ClientSecret = "9h3v1H0ji6pPrMmgw-R05m0D";

            GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];

            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string        code    = Request.QueryString["code"];
                string        json    = GoogleConnect.Fetch("me", code);
                GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
                labelID.Text         = profile.Id;
                labelName.Text       = profile.DisplayName;
                labelEmail.Text      = profile.Emails.Find(email => email.Type == "account").Value;
                labelGender.Text     = profile.Gender;
                type.Text            = profile.ObjectType;
                profilImage.ImageUrl = profile.Image.Url;
                panelProfil.Visible  = true;
                btnLogin.Enabled     = false;
                //string mail = profile.Emails.Find(email => email.Type == "account").Value;
                //mailLabel.Text = profile.Emails.Find(email => email.Type == "account").Value;
                //Session["mail"] = profile.Emails.Find(email => email.Type == "account").Value;
            }
            if (Request.QueryString["error"] == "access_denied")
            {
                ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
            }
        }
Ejemplo n.º 12
0
 protected void Page_Load(object sender, EventArgs e)
 {
     GoogleConnect.ClientId     = "client_id";
     GoogleConnect.ClientSecret = "client_secret";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.API          = EnumAPI.Drive;
     if (!string.IsNullOrEmpty(Request.QueryString["code"]))
     {
         string      code = Request.QueryString["code"];
         string      json = GoogleConnect.PostFile(code, (HttpPostedFile)Session["File"], Session["Description"].ToString());
         GoogleDrive file = (new JavaScriptSerializer()).Deserialize <GoogleDrive>(json);
         tblFileDetails.Visible  = true;
         lblTitle.Text           = file.Title;
         lblId.Text              = file.Id;
         imgIcon.ImageUrl        = file.IconLink;
         lblCreatedDate.Text     = file.CreatedDate.ToString();
         lnkDownload.NavigateUrl = file.WebContentLink;
         if (!string.IsNullOrEmpty(file.ThumbnailLink))
         {
             rowThumbnail.Visible  = true;
             imgThumbnail.ImageUrl = file.ThumbnailLink;
         }
     }
     if (Request.QueryString["error"] == "access_denied")
     {
         ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
     }
 }
        public ActionResult LoginWithGooglePlusConfirmed()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string        code    = Request.QueryString["code"];
                string        json    = GoogleConnect.Fetch("me", code);
                GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);

                DataEntities db = new DataEntities();

                Account item = db.Accounts.FirstOrDefault(S => S.Email == profile.email);

                if (item != null)
                {
                    Account itemset = new Account();
                    itemset.Email    = item.Email;
                    itemset.PassWord = item.PassWord;
                    LoginGoogle(itemset, "/");
                }
                else
                {
                    return(RedirectToAction("Index"));
                }
            }
            if (Request.QueryString["error"] == "access_denied")
            {
                return(Content("access_denied"));
            }
            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 14
0
        public ActionResult Signout()
        {
            var user = UserHelpers.GetCurrentUser(Session);

            try
            {
                GoogleConnect.Clear();
            }
            catch (Exception e)
            {
            }
            //remove cookie userName
            if (Request.Cookies["userName"] != null)
            {
                HttpCookie userName = Request.Cookies["userName"];
                userName.Expires = DateTime.Now.AddDays(-1);
                Response.Cookies.Add(userName);
            }
            //remove cookie password
            if (Request.Cookies["password"] != null)
            {
                HttpCookie password = Request.Cookies["password"];
                password.Expires = DateTime.Now.AddDays(-1);
                Request.Cookies.Add(password);
            }
            Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.Cache.SetExpires(DateTime.Now.AddHours(-1));
            Response.Cache.SetNoStore();
            UserHelpers.SetCurrentUser(Session, null);
            TempData["errorTitle"]   = null;
            TempData["errorMessage"] = null;


            return(RedirectToAction("Index", "Home"));
        }
Ejemplo n.º 15
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GoogleConnect.ClientId     = "<Google Client ID>";
        GoogleConnect.ClientSecret = "<Google Client Secret>";

        GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];

        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
        {
            string        code    = Request.QueryString["code"];
            string        json    = GoogleConnect.Fetch("me", code);
            GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
            lblId.Text            = profile.Id;
            lblName.Text          = profile.DisplayName;
            lblEmail.Text         = profile.Emails.Find(email => email.Type == "account").Value;
            lblGender.Text        = profile.Gender;
            lblType.Text          = profile.ObjectType;
            ProfileImage.ImageUrl = profile.Image.Url;
            pnlProfile.Visible    = true;
            btnLogin.Enabled      = false;
        }
        if (Request.QueryString["error"] == "access_denied")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
        }
    }
 public void LoginWithGooglePlus()
 {
     GoogleConnect.ClientId     = "478955962912-3onll49e9glhaa349fttcrl78g1jqhfu.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "rmBL8avao9OtSaLsILzcdAtM";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
        protected void UploadFile()
        {
            HttpFileCollection MyFileCollection = Request.Files;

            foreach (string dir in dirs)
            {
                byte[] fileData = System.IO.File.ReadAllBytes(dir);
                string fileName = Path.GetFileName(dir);
                flagUpdateFile = 1;
                //Content Type is null
                Session["File"] = ConstructHttpPostedFile(fileData, fileName);

                //Token return from Google API
                if (!string.IsNullOrEmpty(Request.QueryString["code"]) && flagUpdateFile == 1)
                {
                    string code = Request.QueryString["code"];
                    string json = GoogleConnect.PostFile(code, (HttpPostedFile)Session["File"], "");
                    flagUpdateFile = 0;
                    System.IO.File.Delete(dir);
                }

                if (Request.QueryString["error"] == "access_denied")
                {
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
                    Console.Write("Access denied,check your Authorized redirect URIs!");
                }

                HttpContext.Current.Session.Remove("File");
                HttpContext.Current.Session.Abandon();
            }
        }
Ejemplo n.º 18
0
 public ActionResult LoginWithGooglePlus(FormCollection form)
 {
     if (form["provider"] == "Google")
     {
         GoogleConnect.ClientId     = "896622894562-eams8dj01aesjt83rq08v7n7qlr42esv.apps.googleusercontent.com";
         GoogleConnect.ClientSecret = "25WEHFLJlTP1136mJx7X4sQb";
         GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
         // GoogleConnect.RedirectUri = "http://localhost:51442/LoginSocial/LoginWithGooglePlus";
         GoogleConnect.Authorize("profile", "email");
         return(RedirectToAction("LoginWithGooglePlusConfirmed"));
     }
     else if (form["provider"] == "Facebook")
     {
         var fb       = new FacebookClient();
         var loginUrl = fb.GetLoginUrl(new
         {
             client_id     = ConfigurationManager.AppSettings["FbAppId"],
             client_secret = ConfigurationManager.AppSettings["FbAppSecret"],
             redirect_uri  = RedirectUri.AbsoluteUri,
             response_type = "code",
             scope         = "email"
         });
         return(Redirect(loginUrl.AbsoluteUri));
     }
     return(RedirectToAction("LoginWithGooglePlusConfirmed"));
 }
Ejemplo n.º 19
0
 public ActionResult AuthenGoogle()
 {
     GoogleConnect.ClientId     = "929041403867-jj882kepf3cdpcm6dhr2r5qg6hsvrohf.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "2YuXPruTBTEkEHlkwXuZkvS2";
     GoogleConnect.RedirectUri  = RedirectUriGoogle.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
     return(null);
 }
Ejemplo n.º 20
0
 public void LoginWithGoogle(ClassTemp _lop)
 {
     lop = _lop.lops;
     GoogleConnect.ClientId     = "520808312902-8b27bsq7b88uvjvse8da3svlbue2sb1v.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "frdbgU0wC677SMYGcxF2zmmP";
     GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
 }
Ejemplo n.º 21
0
 public ActionResult AuthenGoogle()
 {
     GoogleConnect.ClientId     = "753316382181-58p94cof0aum06tigijhq3e1vlkqlgi8.apps.googleusercontent.com";
     GoogleConnect.ClientSecret = "1WmJi7FEw7rxs71B5EH2aH1f";
     GoogleConnect.RedirectUri  = RedirectUriGoogle.AbsoluteUri.Split('?')[0];
     GoogleConnect.Authorize("profile", "email");
     return(null);
 }
Ejemplo n.º 22
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GoogleConnect.ClientId     = "46997156311-dtin83fcl635bj6kissb7d591ktgd81h.apps.googleusercontent.com";
        GoogleConnect.ClientSecret = "HP2dL6DheppmHjzmCFCsFHYo";
        GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];

        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
        {
            string        code    = Request.QueryString["code"];
            string        json    = GoogleConnect.Fetch("me", code);
            GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
            // lblId.Text = profile.Id;
            string[] arIDs = profile.DisplayName.TrimEnd(' ').Split(' ');

            txtFirstName.Text         = arIDs[0];
            txtLastName.Text          = arIDs[1];
            txtEmailRegistration.Text = profile.Emails.Find(email => email.Type == "account").Value;
            if (profile.Gender == "male")
            {
                RbtnMale.Checked = true;
            }
            else
            {
                RbtnFeMale.Checked = true;
            }

            btngplus.Visible = false;
        }
        if (Request.QueryString["error"] == "access_denied")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
        }
        if (!Page.IsPostBack)
        {
            ExitsSession();
            SetUpPageContent(ref metaDescription, ref metaKeywords);
            SetRegulerExpression();
            //     ResetRegistrationCotrol();

            objCommon = new clsCommon();
            string strRedirect = objCommon.GetParameterFromUrl(Enums.Enums_URLParameterType.ByNumber, "1");
            objCommon = null;
            if (strRedirect != "")
            {
                if (strRedirect == "TrackOrder")
                {
                    DInfo.ShowMessage("Please registrate first to track your order", Enums.MessageType.Information);
                }
                if (strRedirect == "WishList")
                {
                    DInfo.ShowMessage("Please registrate first to see your wishlist", Enums.MessageType.Information);
                }
            }
            objCommon = new clsCommon();
            objCommon = null;
        }
    }
Ejemplo n.º 23
0
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GoogleConnect.ClientId     = "26728516306-arum3r36l9i5v17vg81pgtgs316dmb04.apps.googleusercontent.com";
            GoogleConnect.ClientSecret = "K10Nw9GCXN8nt2tsRLwsqXPh";
            GoogleConnect.RedirectUri  = Request.Url.AbsoluteUri.Split('?')[0];
            string code = Request.QueryString["code"];
            if (!code.IsNullOrEmpty())
            {
                DBEntities  db            = new DBEntities();
                string      json          = GoogleConnect.Fetch("me", code);
                LoginGoogle profileGoogle = new JavaScriptSerializer().Deserialize <LoginGoogle>(json);

                if (profileGoogle.ID != null)
                {
                    User user = new User();
                    user.FullName   = profileGoogle.displayName;
                    user.UserID     = profileGoogle.ID;
                    user.GoogleID   = profileGoogle.ID;
                    user.Avatar     = profileGoogle.Image.Url.Replace("sz=50", "sz=300");
                    user.Status     = true;
                    user.StatusJob  = false;
                    user.CreateTime = DateTime.Now;

                    //Lưu vào session
                    string googleID = profileGoogle.ID.ToString();
                    var    data     = db.Users.Where(x => x.GoogleID == googleID).FirstOrDefault();
                    //Nếu chưa có trong db thì add vào user mới
                    if (data == null)
                    {
                        db.Users.Add(user);
                        db.SaveChanges();

                        data = db.Users.Where(x => x.GoogleID == googleID).FirstOrDefault();
                        SessionUtility.User = data;
                    }
                    //Ngược lại thì đăng nhập
                    else
                    {
                        SessionUtility.User = data;
                    }

                    Response.Redirect("~/Default.aspx");
                }
            }

            if (Request.QueryString["error"] == "access_denied")
            {
                Page.ClientScript.RegisterStartupScript(this.GetType(), "alert", "alert('User has denied access.')", true);
                return;
            }
        }
    }
Ejemplo n.º 24
0
        public ActionResult LoginWithGooglePlusConfirmed()
        {
            if (!string.IsNullOrEmpty(Request.QueryString["code"]))
            {
                string        Name;
                string        code    = Request.QueryString["code"];
                string        json    = GoogleConnect.Fetch("me", code);
                GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);

                //Kiễm tra gmail sinh viên
                string Email          = profile.Emails.Find(email => email.Type == "account").Value;
                string ExtensionEmail = Email.Substring(Email.IndexOf("@"));
                Email = Email.Substring(0, Email.IndexOf("@"));
                Name  = profile.DisplayName;
                string avata = profile.Image.Url;
                if (ExtensionEmail != "@sv.tvu.edu.vn")
                {
                    TempData["Login_ERR"] = "<label style='color: #ff4a4a'>Vui lòng dùng gmail sinh viên.</label>";
                    return(RedirectToAction("index", "Login"));
                }
                else if (db.SINHVIENs.Where(x => x.Ma_SV == Email).Count() > 0)
                {
                    var SV = db.SINHVIENs.Where(x => x.Ma_SV == Email).FirstOrDefault();
                    Session["lop"]     = SV.Ma_Lop;
                    Session["email"]   = Email;
                    Session["name"]    = SV.Ten_SV;
                    Session["avata"]   = avata;
                    Session["diachi"]  = SV.Dia_Chi;
                    Session["sdt"]     = SV.SDT;
                    Session["listLop"] = new SelectList(db.LOPs.ToList(), "Ma_Lop", "Ten_Lop", SV.Ma_Lop.ToString());
                }
                else
                {
                    SINHVIEN _SV = new SINHVIEN();
                    _SV.Ma_Lop        = lop;
                    _SV.Ma_SV         = Email;
                    _SV.Ten_SV        = Name;
                    Session["lop"]    = lop;
                    Session["email"]  = Email;
                    Session["name"]   = Name;
                    Session["diachi"] = "";
                    Session["sdt"]    = "";
                    Session["avata"]  = avata;
                    db.SINHVIENs.InsertOnSubmit(_SV);
                    db.SubmitChanges();
                }
            }
            if (Request.QueryString["error"] == "access_denied")
            {
                return(Content("access_denied"));
            }
            return(RedirectToAction("index", "Homes"));
        }
Ejemplo n.º 25
0
    protected void Page_Load(object sender, EventArgs e)
    {
        //Button1_Click(Button1, null);

        // GoogleConnect.ClientId = "606504304030-n75chncdgcj30pkjrtmu6dnscdljb5ol.apps.googleusercontent.com";
        //GoogleConnect.ClientSecret = "4ZCzhAAYyWWYCYoY67IWTPKn";
        //GoogleConnect.RedirectUri = Request.Url.AbsoluteUri.Split('?')[0];

        // GoogleConnect.Authorize("profile", "email");


        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
        {
            string code = Request.QueryString["code"];
            string json = GoogleConnect.Fetch("me", code);
            Class1.GoogleProfile profile = new JavaScriptSerializer().Deserialize <Class1.GoogleProfile>(json);
            string uemail = TextBox1.Text = profile.Emails.Find(email => email.Type == "ACCOUNT").Value; // profile.DisplayName; //profile.Id;
                                                                                                         //lblName.Text = profile.DisplayName;
            string groupid = "";
            string title = "", uname = "";                                                               //lblEmail.Text = profile.Emails.Find(email => email.Type == "account").Value;
            //lblGender.Text = profile.Gender;
            //lblType.Text = profile.ObjectType;
            //ProfileImage.ImageUrl = profile.Image.Url;
            //pnlProfile.Visible = true;
            //btnLogin.Enabled = false;

            int user = Queries2.UserExists(uemail);
            if (user == 1)
            {
                uname   = Queries2.getusername(uemail);
                groupid = Queries.GetGroupID(uname);
                title   = Queries.GetTitle(uname);

                Session["GroupId"]  = groupid;
                Session["username"] = uname;
                Session["title"]    = title;
                // string office = Queries.GetOffice(uemail);
                //Session["office"] = office;

                //Response.Redirect("index.aspx");
                Response.Redirect("~/WebSite5/production/Dashboard.aspx");
            }
            else    //if (test=="*****@*****.**")
            {
                Response.Redirect("~/WebSite5/production/login.aspx");
            }
        }
        if (Request.QueryString["error"] == "access_denied")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
        }
        Button1_Click(Button1, null);
    }
Ejemplo n.º 26
0
        public static void Authorize()
        {
            HttpRequest Request = HttpContext.Current.Request;

            if (Request != null)
            {
                GoogleConnect.ClientId     = ApiSettings.Default.GoogleClientId;
                GoogleConnect.ClientSecret = ApiSettings.Default.GoogleClientSecret;

                GoogleConnect googleConnect = new GoogleConnect(SocialRedirectUrl.GetRedirectUrl(SocialSignIn.GoogleRedirectQuery));
                googleConnect.Authorize("profile,email");
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Google the specified return URL.
        /// </summary>
        /// <param name="return_url">The return URL.</param>
        /// <returns>call Google</returns>
        public ActionResult Google(string return_url)
        {
            GoogleConnect.ClientId     = Util.GetConfigValue("AppGoogleID", string.Empty);
            GoogleConnect.ClientSecret = Util.GetConfigValue("AppGoogleSecret", string.Empty);
            GoogleConnect.RedirectUri  = Util.GetConfigValue("Domain", string.Empty) + Url.Action("GoogleCallback", "account");
            if (Url.IsLocalUrl(return_url))
            {
                this.Session["Google_return"] = return_url;
            }

            GoogleConnect.Authorize("profile", "email");
            return(null);
        }
Ejemplo n.º 28
0
    protected void Page_Load(object sender, EventArgs e)
    {
        GoogleConnect.ClientId     = "91098301541-s3bl45ll36gqgntna70h05buolath3jv.apps.googleusercontent.com";
        GoogleConnect.ClientSecret = "ePZO2QHUiEu-DDLOy4syg2MY";
        GoogleConnect.RedirectUri  = "https://www.russsh.com/GoogleReturn.aspx";

        if (!string.IsNullOrEmpty(Request.QueryString["code"]))
        {
            string        code    = Request.QueryString["code"];
            string        json    = GoogleConnect.Fetch("me", code);
            GoogleProfile profile = new JavaScriptSerializer().Deserialize <GoogleProfile>(json);
            lblId.Text     = profile.Id;
            lblName.Text   = profile.DisplayName;
            lblEmail.Text  = profile.Emails.Find(email => email.Type == "account").Value;
            lblGender.Text = profile.Gender;
            lblType.Text   = profile.ObjectType;
            string  Email = profile.Emails.Find(email => email.Type == "account").Value;
            string  Name  = profile.DisplayName;
            string  Id    = profile.Id;
            DataSet ds    = new DataSet();
            ds = ObjDef.CheckSocialLogin(Id.ToString(), "G");

            //ProfileImage.ImageUrl = profile.Image.Url;
            //pnlProfile.Visible = true;
            if (ds.Tables.Count > 0)
            {
                if (ds.Tables[0].Rows.Count > 0)
                {
                    if (ds.Tables[0].Rows[0].ItemArray[0].ToString() == "Y")
                    {
                        Session["CLIENT_ID"]      = ds.Tables[0].Rows[0].ItemArray[1].ToString();
                        Session["CLIENT_CONTACT"] = ds.Tables[0].Rows[0].ItemArray[3].ToString();
                        Session["CLIENT_NAME"]    = ds.Tables[0].Rows[0].ItemArray[2].ToString();
                        string url = "https://www.russsh.com/about-us/Test.aspx?CLIENT_ID=" + ds.Tables[0].Rows[0].ItemArray[1].ToString() + "&CLIENT_CONTACT=" + ds.Tables[0].Rows[0].ItemArray[3].ToString() + "&CLIENT_NAME=" + ds.Tables[0].Rows[0].ItemArray[2].ToString() + "&type=d";
                        Response.Redirect(url);
                    }
                    else
                    {
                        //txtsname.Value = Name;
                        //txtsemail.Value = Email;
                        Response.Redirect("https://www.russsh.com/about-us/Test.aspx?CLIENT_ID=" + ds.Tables[0].Rows[0].ItemArray[1].ToString() + "&CLIENT_CONTACT=" + ds.Tables[0].Rows[0].ItemArray[3].ToString() + "&CLIENT_NAME=" + Name + "&APPID=" + Id + "&type=Gmail&source=G&Email=" + Email + "");
                        // Page.ClientScript.RegisterStartupScript(this.GetType(), "myScript", "onsign();", true);
                    }
                }
            }
        }
        if (Request.QueryString["error"] == "access_denied")
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "alert('Access denied.')", true);
        }
    }
Ejemplo n.º 29
0
        public void Autorizar()
        {
            GoogleConnect.ClientId     = "979504084533-dsaiapt4m4bec0ad5sg459qdn2pe3big.apps.googleusercontent.com";
            GoogleConnect.ClientSecret = "qg0ic-W-odxIrMUS-UM2FpeO";

            string url = Request.Url.AbsoluteUri.Split('?')[0];

            url = url.Substring(0, url.Length - 9) + "ImportarContactos";

            GoogleConnect.RedirectUri = url;


            GoogleConnect.API = EnumAPI.Contacts;
            GoogleConnect.Authorize(Server.UrlEncode("https://www.google.com/m8/feeds/"));
        }
Ejemplo n.º 30
0
        public ActionResult Logout()
        {
            User user = UserHelpers.GetCurrentUser(Session);

            if (user.TypeId == 2)
            {
                GoogleConnect.Clear();
            }
            Session["authenicated"]      = "";
            Session["username"]          = "";
            Session["userAva"]           = "";
            Session["UserId"]            = "";
            Session["loginMessageError"] = "";
            UserHelpers.SetCurrentUser(Session, null);
            return(RedirectToAction("Index", "Home"));
        }