Пример #1
0
        public ActionResult Auth()
        {
            var yandex = YandexAuth.GetUser(Request);
            var mail   = MailAuth.GetUser(Request);

            return(PartialView("AuthPartialView", mail));
        }
Пример #2
0
        public ActionResult LoginWithYandex(string code)
        {
            var accessToken = YandexAuth.GetAuthorizationCookie(Response.Cookies, code, Db);

            FormsAuthentication.SetAuthCookie(accessToken, true);

            return(RedirectToActionPermanent("Index", "Home"));
        }
Пример #3
0
        /// <summary>
        /// Сюда приходит после авторизации на яндексе
        /// </summary>
        /// <returns></returns>
        public ActionResult LoginWithYandex()
        {
            var model = YandexAuth.GetToken(Request);

            var userCookie = YandexAuth.TokenCookie(model);

            Response.Cookies.Set(userCookie);

            return(RedirectToActionPermanent("Index", "Home"));
        }
Пример #4
0
        public ActionResult LoginWithYandex(string code)
        {
//            var userCookie = YandexAuth.GetAuthorizationCookie(Request);
            //  MonitorLog.WriteLog(string.Format("GetAuthorizationCookie({0})", Repository), MonitorLog.typelog.Info, true);
            var accessToken = YandexAuth.GetAuthorizationCookie(Response.Cookies, code, Db);

            //  MonitorLog.WriteLog(string.Format("accessToken = {0}", accessToken), MonitorLog.typelog.Info, true);

            FormsAuthentication.SetAuthCookie(accessToken, true);

            return(RedirectToActionPermanent("Index", "Home"));
        }
Пример #5
0
        public ActionResult Add(News news)
        {
            var user = YandexAuth.GetUser(Request);

            //найдём пользователя в БД
            var list = MvcApplication.Db.Where <User>(u => u.Login == user.display_name);

            if (list.Any())
            {
                news.LogDate = DateTime.Now;
                news.User    = new User {
                    Id = list.FirstOrDefault().Id
                };

                var result = MvcApplication.Db.Save(news);
                return(RedirectToAction("Single", new { newsId = result }));
            }
            return(RedirectToAction("Index", "Home"));
        }