Exemplo n.º 1
0
        private bool TestCommand(SetToken evt, out IEvent e)
        {
            e = null;
            if (user == null)
            {
                return(false);
            }

            if (user.Tokens == null)
            {
                e = new TokenAdded(evt.LoginProvider, evt.Name, evt.Value);
            }
            else
            {
                ImmutableIdentityUserToken token = user.Tokens.FirstOrDefault(x => x.LoginProvider.Equals(evt.LoginProvider) && x.Name.Equals(evt.Name));
                if (token == default(ImmutableIdentityUserToken))
                {
                    e = new TokenAdded(evt.LoginProvider, evt.Name, evt.Value);
                }
                else if (token.Value.Equals(evt.Value))
                {
                    e = new TokenUpdated(evt.LoginProvider, evt.Name, evt.Value);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        public OperationResult SetToken(SetToken command)
        {
            var operation = new OperationResult();
            var account   = _accountRepository.Get(command.Id);

            if (account == null)
            {
                return(operation.Failed(ApplicationMessages.RecordNotFound));
            }

            account.SetToken(command.Token);
            _accountRepository.SaveChanges();
            return(operation.Succedded());
        }
Exemplo n.º 3
0
        public static MethodBuilder DefineMethod(this TypeBuilder builder, string name, MethodAttributes attributes, MethodSignature signature)
        {
            var t    = TypeOf <MethodBuilder> .TypeID;
            var modb = (ModuleBuilder)builder.Module;
            var mod  = GetNativeModule(modb);

            byte[]        sig = signature.GetSignature(modb);
            int           tok = DefineMethodInternal.Invoke(mod, builder.TypeToken.Token, name, sig, sig.Length, attributes);
            MethodBuilder mb  = NewMethod.Invoke(
                name, attributes, signature.CallingConvention, signature.ReturnType,
                signature.ParameterTypes, modb, builder, false
                );

            mb.GetToken();             //returns 0 but circumvents the RSA error (?)
            SetToken.Invoke(mb, NewMethodToken(tok));
            GetMethodList.Invoke(builder).Add(mb);
            return(mb);
        }
 public List <string> UsersTokenValidation([FromBody] SetToken tokenEncrypted)
 {
     return(SignIn.TokenValidation(tokenEncrypted.TokenString));
 }//set user token validation