Beispiel #1
0
        public ActionResult Confirm()
        {
            var obj = new LinkedInConnector(HttpContext, ControllerContext);

            obj.CallBack();

            var model = obj.GetUserProfile();

            var user = ((UserService)_serviceUserList).GetByName(model.Email);

            if (model.Id == 0)
            {
                user = _serviceUserList.Create(model);
            }

            FormsAuthentication.SetAuthCookie(model.Email, true);


            SessionHelper.CurrentUser = user;

            //TODO Create companyId in the MasterId
            Session["company_id"] = 0;// SessionHelper.CurrentUser.;

            return(RedirectToAction("Index", "Home"));
        }
Beispiel #2
0
        //[AllowAnonymous]
        public ActionResult AddAccount()
        {
            var obj = new LinkedInConnector(HttpContext, ControllerContext);

            obj.CallBack();

            var model   = obj.GetUserProfile();
            var session = _accessor.Current().Session;

            if (session != null)
            {
                var currentUser = session["CurrentUser"] as UserModel;
                if (currentUser != null)
                {
                    var user = ((UserService)_userService).UpdateUserWithLinkedId(currentUser.Id, model.LinkedInId);

                    session["CurrentUser"] = user;
                }
            }


            //if (string.IsNullOrEmpty(model.UserName))
            //    //model.UserName = string.Concat(model.FirstName, model.LastName);
            //    model.UserName = string.Concat(model.FirstName, model.LastName);

            //var user = ((UserService)_userService).GetByLinkedInId(model.UserName);



            //prevent login with empty passowrd
            //model.Password = GenerateRandomPassword();

            //if ((user == null) || (user != null && user.Id == 0))
            //{

            //    if (string.IsNullOrEmpty(model.CompanyName)) model.CompanyName = string.Empty;

            //    user = _userService.Create(model);
            //    if (user.Id > 0)
            //    {
            //        //FormsAuthentication.SetAuthCookie(model.UserName, true);

            //        var iUser = _membershipService.ValidateUser(model.UserName, model.Password);
            //        _authenticationService.SignIn(iUser, true);
            //    }
            //}
            //else
            //{
            //    var iUser = _membershipService.ValidateUser(user.UserName, user.Password);
            //    _authenticationService.SignIn(iUser, true);
            //}

            //TODO Create companyId in the MasterId
            //Session["company_id"] = 0;// SessionHelper.CurrentUser.;

            // return RedirectToAction("Index", "Home");
            return(RedirectToAction("Index", "Account"));
        }
Beispiel #3
0
        public ActionResult Confirm()
        {
            var obj = new LinkedInConnector(HttpContext, ControllerContext);

            obj.CallBack();

            var model = obj.GetUserProfile();

            //var user = ((UserService)_userService).GetByLinkedInId(model.UserName);
            var user = ((UserService)_userService).GetByLinkedInId(model.LinkedInId);

            //prevent login with empty passowrd
            model.Password = GenerateRandomPassword();

            if ((user == null) || (user != null && user.Id == 0))
            {
                if (string.IsNullOrEmpty(model.CompanyName))
                {
                    model.CompanyName = string.Empty;
                }
                if (user == null)
                {
                    model.ActivationDate   = DateTime.Now;
                    model.UserName         = string.IsNullOrEmpty(model.FirstName) ? "" : model.FirstName;
                    model.CompanyName      = "";
                    model.MaxJigsawExports = 0;
                    model.MaxJigsawReportsViewsPerMonth = model.MaxJigsawReportsViewsPerYear = model.MaxReportViewsPerMonth = model.MaxReportViewsPerYear = model.MaxExports = 0;
                    model.TestAccount = model.ShowCarrier = model.ShowStatusFld = model.InternalAccount = false;
                }
                user = _userService.Create(model);
                if (user.Id > 0)
                {
                    //FormsAuthentication.SetAuthCookie(model.UserName, true);

                    var iUser = _membershipService.ValidateUser(model.Email, model.Password);
                    _authenticationService.SignIn(iUser, true);
                }
            }
            else
            {
                var iUser = _membershipService.ValidateUser(user.Email, user.Password);
                _authenticationService.SignIn(iUser, true);
            }

            //TODO Create companyId in the MasterId
            //Session["company_id"] = 0;// SessionHelper.CurrentUser.;

            return(RedirectToAction("Index", "Account"));
            // return Redirect("../Account/Index");
        }