コード例 #1
0
        public ActionResult Authenticate(string token, string returnUrl)
        {
            if (string.IsNullOrEmpty(token))
            {
                return ReturnWithError(returnUrl);
            }

            var rpx = new Rpx("87df721ebccbde5919f4258b45d8f3d0dc1db546", "https://shcil.rpxnow.com/");
            var response = rpx.AuthInfo(token);
            var parser = new RpxResponseParser(response);
            if (parser.Status != RpxReponseStatus.Ok)
            {
                return ReturnWithError(returnUrl);
            }
            else
            {
                var responseUser = parser.BuildUser();
                var user = _usersRepository.FindByOpenId(responseUser.OpenId);
                if (user == null)
                {
                    user = new User {
                        Email = responseUser.Email,
                        Friendly = responseUser.Friendly,
                        OpenId = responseUser.OpenId,
                        UserName = responseUser.UserName
                    };
                    DB.Users.Insert(user);
                }

                Response.AppendCookie(new HttpCookie("userId", user.Id.ToString()));

                return ReturnToUrl(returnUrl);
            }
        }
コード例 #2
0
ファイル: UsersRepository.cs プロジェクト: lgadi/ZeeBi
 public void Add(User user)
 {
     DB.Users.Insert(user);
 }