Esempio n. 1
0
        public static void Init()
        {
            if (!inited)
            {
                var connString = ConfigurationManagerWrapper.GetDBConnectionString("FCTestDB");
                var connProvider = ConfigurationManagerWrapper.GetProviderName("FCTestDB");
                var mqConnectionString = ConfigurationManagerWrapper.GetMessageQueueServerConnectionString("messageQueueServerConnectString");

                var assemblies = GetAllAssembly();
                var nhibernateMapperAssemblies = assemblies.Where(ass => ass.FullName.IndexOf("DotPay.Persistence", StringComparison.OrdinalIgnoreCase) > -1);

                FCFramework.Initialize().UseAutofac()
                                        .UseCouchbaseCache()
                                        .UseLog4net()
                                        .UseDefaultCommandBus(assemblies)
                                        .UseNHibernate(new ConnectionString(connString, connProvider), nhibernateMapperAssemblies)
                                        .RegisterAllRepository()
                                        .RegisterQueryServices(new ConnectionString(connString, connProvider))
                                        .UseDefaultEventBus(assemblies)
                                        .Start();
                inited = true;
                SessionManager.CreateTables();

                int i = 0;
                while (i < 10)
                {
                    i++;
                    var cmd = new UserRegister(Guid.NewGuid().Shrink(), "email" + i.ToString() + "@11.com", "1", "1", 8,"adsjfljasdljflasdjf");

                    IoC.Resolve<ICommandBus>().Send(cmd);
                }
            }
        }
Esempio n. 2
0
        public void TestUserRegisterAndLogin()
        {
            var password = Guid.NewGuid().Shrink();
            var email = "test" + password.GetHashCode() + "@mytest.com";
            //var rippleAddress = "test" + password.GetHashCode() + "@mytest.com";
            //var rippleSecret = "test" + password.GetHashCode() + "@mytest.com";

            var cmd = new UserRegister(Guid.NewGuid().Shrink(), email, password, password, 8, "asdjlfjadljflasdjflsjdf");
            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(cmd);
            });

            var savedUser = IoC.Resolve<IUserRepository>().FindByEmail(email);

            Assert.NotNull(savedUser);
            Assert.Equal(savedUser.Email, email);
            Assert.True(savedUser.ID > 0);
            Assert.Null(savedUser.GoogleAuthentication);
            Assert.Null(savedUser.SmsAuthentication);

            var loginCmd = new UserLogin(email, password, "192.168.0.6");

            Assert.DoesNotThrow(delegate
            {
                this.commandBus.Send(loginCmd);
            });
        }
Esempio n. 3
0
        public ActionResult RegisterPost(string loginName, string password, string paypassword)
        {
            var result = FCJsonResult.UnknowFail;

            if (Session["PreRegistrationEmail"] != null && Session["PreRegistrationToken"] != null)
            {
                var email = Session["PreRegistrationEmail"].ToString();
                var token = Session["PreRegistrationToken"].ToString();
                loginName = loginName.NullSafe().Trim();

                var tmpObj = new object();

                if (!string.IsNullOrEmpty(loginName) && email.NullSafe().IsEmail() && !string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(paypassword))
                {
                    if (!IoC.Resolve<IPreRegistratorQuery>().ExistRegisterEmailWithToken(email, token))
                        result = FCJsonResult.CreateFailResult(this.Lang("An account with that email address already exists. Please try again or use the forgotten password feature."));
                    else
                    {
                        try
                        {
                            var cmd = new UserRegister(loginName, email, password, paypassword, 8, token);
                            this.CommandBus.Send(cmd);
                            var loginUser = IoC.Resolve<IUserQuery>().GetUserByEmail(email);
                            Session[Constants.TmpUserKey] = loginUser;

                            this.CurrentUserPassTwoFactoryVerify();
                            result = FCJsonResult.Success;
                        }
                        catch (CommandExecutionException ex)
                        {
                            Log.Error("Action UserRegistter Error", ex);
                        }
                    }
                }
            }

            return Json(result);
        }