Esempio n. 1
0
        public ActionResult GetDataFromNetwork()
        {
            var uLoginUser = ULoginHelper.GetULoginUser(
                this.Request.Form["token"],
                this.Request.ServerVariables["SERVER_NAME"]);

            //If user account is already exist redirect to login method
            if (UserManager.NetworkAccountExict(uLoginUser.Uid, uLoginUser.Network))
            {
                return(NetworkLogin());
            }

            var user = new NetworkUserDTO()
            {
                UserName         = ULoginHelper.GetName(uLoginUser),
                Email            = uLoginUser.Email,
                Network          = uLoginUser.Network,
                NetworkAccountId = uLoginUser.Uid
            };

            if (user.Email == null)
            {
                return(View("EnterEmail", user));
            }

            return(NetworkSignUp(user));
        }
Esempio n. 2
0
        public ActionResult NetworkLogin()
        {
            var uLoginUser = ULoginHelper.GetULoginUser(
                this.Request.Form["token"],
                this.Request.ServerVariables["SERVER_NAME"]);

            NetworkUserDTO user = UserManager.GetNetworkUser(uLoginUser.Uid, uLoginUser.Network);

            if (user == null)
            {
                return(View("NetworkErrMessage"));
            }

            var claim = new ClaimsIdentity("ApplicationCookie", ClaimsIdentity.DefaultNameClaimType,
                                           ClaimsIdentity.DefaultRoleClaimType);

            claim.AddClaim(new Claim(ClaimTypes.NameIdentifier, user.Id.ToString(), ClaimValueTypes.String));
            claim.AddClaim(new Claim(ClaimsIdentity.DefaultNameClaimType, user.UserName, ClaimValueTypes.String));
            claim.AddClaim(
                new Claim("http://schemas.microsoft.com/accesscontrolservice/2010/07/claims/identityprovider",
                          "OWIN Provider", ClaimValueTypes.String));
            claim.AddClaim(new Claim(ClaimsIdentity.DefaultRoleClaimType, user.RoleName, ClaimValueTypes.String));

            AuthenticationManager.SignOut();
            AuthenticationManager.SignIn(new AuthenticationProperties {
                IsPersistent = true
            }, claim);
            return(RedirectToAction("Index", "Home"));
        }