public LiveIDAccountInfo getAccountInfo()
        {
            var payload = JwtPayload.Base64UrlDeserialize(this.id_token.Split('.')[1]);
            var json    = payload.SerializeToJson();
            LiveIDAccountInfo account_info = Newtonsoft.Json.JsonConvert.DeserializeObject <LiveIDAccountInfo>(json);

            return(account_info);
        }
Example #2
0
        protected override ActionResult <User> ActionImplemetation()
        {
            if (string.IsNullOrEmpty(input))
            {
                return new ActionResult <User> {
                           isSuccessfull = false, message = "code not given"
                }
            }
            ;

            var liveIDconf = this.getGlobalObject <IConfigurationProvider>().getConfiguration <LiveIDConfiguration>();
            LiveIdAccessTokenInfo access_token_info = LiveIdAccessTokenInfo.Aquire(input, liveIDconf);

            LiveIDAccountInfo account_info = access_token_info.getAccountInfo();

            //live id cookies
            var  cd   = this.getGlobalObject <IContentDispatcher>();
            User user = cd.GetAllByFilter <User>(x => x.email == account_info.email).FirstOrDefault();

            //first time in this instance
            if (user == null)
            {
                if (!liveIDconf.allow_new_users)
                {
                    return(ActionResultTemplates <User> .UnAuthorized);
                }

                var cc = this.getGlobalObject <IGlobalContentCreator>();

                user = cc.getNewContent <User>();
            }
            user.username = account_info.preferred_username;
            user.fullname = account_info.name;
            user.email    = account_info.email;
            cd.Add(user);

            var session = this.getGlobalObject <MysterySession>();

            session.authenticated_user = user;

            return(new ActionResult <User>(user));
        }