Example #1
0
        ////////////////////////////////////////////////////////////////////////////////////////////////
        /*--------------------------------------------------------------------------------------------*/
        public void ExecuteOauth()
        {
            if (vOauthToken == null)
            {
                vActiveMember = null;
                return;
            }

            vActiveMember = vMemCache.FindOauthMember(vOauthToken);

            if (vActiveMember != null)
            {
                return;
            }

            ////

            IWeaverQuery q = Weave.Inst.Graph
                             .V.ExactIndex <OauthAccess>(x => x.Token, vOauthToken)
                             .Has(x => x.Expires, WeaverStepHasOp.GreaterThan, vGetUtcNow())
                             .AuthenticatesMember.ToMember
                             .ToQuery();

            vActiveMember = vGetDataAcc()
                            .AddQuery(q)
                            .Execute("MemberForOauthToken")
                            .ToElement <Member>();

            if (vActiveMember == null)
            {
                throw new FabOauthFault();
            }

            switch ((MemberType.Id)vActiveMember.MemberType)
            {
            case MemberType.Id.None:
            case MemberType.Id.Invite:
            case MemberType.Id.Request:
                vActiveMember = null;
                throw new FabOauthFault();
            }

            ////

            long exp    = (vActiveMember.OauthGrantExpires ?? 0);
            var  expSec = (int)(new TimeSpan(exp - vGetUtcNow()).TotalSeconds);

            vMemCache.AddOauthMember(vOauthToken, vActiveMember, expSec);
        }