public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IGoogleService googleService, IFacebookService facebookService, IAppleService appleService) : base(navigationService) { _pageDialogService = pageDialogService; _googleService = googleService; _facebookService = facebookService; _appleService = appleService; _multiFactorService = new MultiFactorService(this); Title = "Main Page"; _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) => { _isSignedIn.Value = auth.CurrentUser != null; }); ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand(); SignUpCommand.Subscribe(SignUp); SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword); SignInWithGoogleCommand.Subscribe(SignInWithGoogle); SignInWithTwitterCommand.Subscribe(() => SignInWithProvider("twitter.com")); SignInWithFacebookCommand.Subscribe(SignInWithFacebook); SignInWithGitHubCommand.Subscribe(() => SignInWithProvider("github.com")); SignInWithYahooCommand.Subscribe(() => SignInWithProvider("yahoo.com")); SignInWithMicrosoftCommand.Subscribe(() => SignInWithProvider("microsoft.com")); SignInWithAppleCommand.Subscribe(SignInWithApple); SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber); SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously); ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>()); }
public ChatVM(IClientHubProxy _clientHubProxy, IDispatcher Dispatcher) { //Needed to get UI dispatcher. would be great to abstract out and get handed the UI dispatcher through constructor injection UIDispatcher = Dispatcher; //example and the one used in test: clientHubProxy = new ClientHubProxy("http://localhost:8080", "chat"); clientHubProxy = _clientHubProxy; clientHubProxy.startHub(); //Register events and event handlers clientHubProxy.MessageReceived += receivedMessage; clientHubProxy.UsernameReceived += receivedUsername; clientHubProxy.LogReceived += receivedLog; clientHubProxy.UsernamesReceived += receivedUsernames; clientHubProxy.LocalUsernameReceived += receivedLocalUser; clientHubProxy.UsernameReceivedDisconnect += removeUser; var b = new Parcel(new Entities.Message("TestUseBoy"), new User(new Value_Objects.Username("NuttyBoi"), new Value_Objects.Password(""))); MessageCommand = new SendCommand(new Action <object>((a) => sendMessage(new Parcel(new Entities.Message(ChatMessageToSend), new User(new Value_Objects.Username(LocalUser), new Value_Objects.Password(LocalUser)))))); GetLogCommand = new SendCommand(new Action <object>((a) => getLog())); LoginCommand = new LoginCommand(new Action <object>((a) => getLogin(new User(new Value_Objects.Username(userLogin), new Value_Objects.Password(userPass))))); SignUpCommand = new SignUpCommand(new Action <object>((a) => getSignUp(new User(new Value_Objects.Username(LocalUser), new Value_Objects.Password(LocalUser))))); //Login action so to speak setName(); }
public async Task HappyPath() { var sut = _fixture.GetClient <IIdentityApi>(); var command = new SignUpCommand("*****@*****.**", "TEest12!@"); var result = await sut.SignUp(command); result.IsSuccessStatusCode.Should().BeTrue(); var mailService = (FakeMailService)_fixture.GetService <IMailService>(); mailService.Messages.Should() .HaveSingleMailWithProperReceiverAndSender(@from: "*****@*****.**", to: command.Email).And .ContainProperLink(); var link = EmailContentExtractor.GetUrlFromActivationMail(mailService.Messages.First()); var(userId, token) = EmailContentExtractor.GetQueryParams(link); var result2 = await sut.ActivateAccount(new ActivateCommand(Guid.Parse(userId), token, "test_nickname")); result2.IsSuccessStatusCode.Should().BeTrue(); var user = await sut.SignIn(new SignInCommand(command.Email, command.Password)); user.Token.Should().NotBeEmpty(); var meResult = await sut.Me(user.BearerToken()); meResult.Id.Should().NotBeEmpty(); meResult.Email.Should().Be(command.Email); }
public override async Task <SignUpResponse> SignUp(SignUpRequest request, ServerCallContext context) { var signUpModel = new SignUpModel { CompanyName = request.CompanyName, FirstName = request.FirstName, LastName = request.LastName, Phone = request.Phone, Website = request.Website, Email = request.Email, Password = request.Password, RoleName = request.RoleName }; var signUpCommand = new SignUpCommand(signUpModel); var result = await _commandBus.TransactionSendAsync(signUpCommand); if (result.IsOk) { var response = result.Value as dynamic; return(new SignUpResponse { UserId = response.UserId, Link = response.Link }); } var statusCode = (StatusCode)result.StatusCode; throw new RpcException(new Status(statusCode, result.Value?.ToString())); }
public MainPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService, IAuthService authService) : base(navigationService) { _pageDialogService = pageDialogService; _authService = authService; Title = "Main Page"; _registration = CrossFirebaseAuth.Current.Instance.AddAuthStateChangedListener((auth) => { _isSignedIn.Value = auth.CurrentUser != null; }); ShowUserCommand = _isSignedIn.ToAsyncReactiveCommand(); SignUpCommand.Subscribe(SignUp); SignInWithEmailAndPasswordCommand.Subscribe(SignInWithEmailAndPassword); SignInWithGoogleCommand.Subscribe(SignInWithGoogle); SignInWithTwitterCommand.Subscribe(SignInWithTwitter); SignInWithFacebookCommand.Subscribe(SignInWithFacebook); SignInWithGitHubCommand.Subscribe(SignInWithGitHub); SignInWithPhoneNumberCommand.Subscribe(SignInWithPhoneNumber); SignInAnonymouslyCommand.Subscribe(SignInSignInAnonymously); ShowUserCommand.Subscribe(async() => await NavigationService.NavigateAsync <UserPageViewModel>()); }
public async Task <ApiRequestResult> SignUpAsync(SignUpCommand command) { await _identityServices.SignUpAsync(command.Email, command.PhoneNumber, command.UserName, command.Password, UserType.Member); return(ApiRequestResult.Success("注册成功")); }
public async Task Handle_ValidRequest_HappyFlow() { // Arrange SignUpCommand request = new SignUpCommand { FullName = ConstantsAccountsCQTest.Username, Email = ConstantsAccountsCQTest.Email, Password = ConstantsAccountsCQTest.Password }; _accountRepositoryMock.Setup(x => x.ExistsAccount(request.Email)).Returns(false); _accountRepositoryMock.Setup(x => x.SaveModifications()).Returns(Results.Ok()); // Act Result result = await _handler.Handle(request, CancellationToken.None); // Assert result.IsSuccess.Should().BeTrue(); Account newAccount = new Account() { Email = request.Email.ToLower(), Username = request.FullName, Password = request.Password }; // Verify CreateAccount method receive the Account object with the properly attributes _accountRepositoryMock .Verify(x => x.CreateAccount( It.Is <Account>(x => x.Password == newAccount.Password && x.Email == newAccount.Email.ToLower() && x.Username == newAccount.Username)), Times.Once); }
public SignResponse SignUp(SignUpCommand command) { if (_recruitersRepository.Exists(rec => rec.Email == command.Email)) { return new SignResponse() { CanSignIn = false } } ; RecruiterEntity newEntity = _recruitersRepository.Add(new RecruiterEntity() { Email = command.Email, Password = command.Password, Gender = Gender.Unknown, RegisterStatus = RecruiterRegisterStatus.Register, SourceType = RecruiterSourceType.System, CreatedAt = DateTime.Now, UpdatedAt = DateTime.Now, //RegisterStatusHistory = new List<BaseStatusHistory>() { new BaseStatusHistory() { Status = RecruiterRegisterStatus.Register, Date = DateTime.Now } }, FriendlyId = _recruitersRepository.GetNextId <RecruiterEntity>() }); return(new SignResponse() { CanSignIn = true, UserId = newEntity.Id, UserType = CvLocate.Common.EndUserDtoInterface.Enums.UserType.Recruiter }); } #endregion }
public async Task Should_Create_New_Account() { SignUpCommand command = new SignUpCommand { Email = "*****@*****.**", Name = "Jubileu antunes", Password = "******", Picture = null }; _userReadOnlyRepository .Setup(x => x.Any(command.Email)) .ReturnsAsync(false); _accountWriteOnlyRepository .Setup(x => x.Create(It.IsAny <Account>())); _userWriteOnlyRepository .Setup(x => x.Create(It.IsAny <User>())); SignUpResult result = await signUpUseCase.Execute(command); Assert.NotNull(result); Assert.NotEqual(Guid.Empty, result.UserId); Assert.NotEqual(Guid.Empty, result.AccountId); }
public async Task <ActionResult> SignUp([FromBody] SignUpRequest request) { var command = new SignUpCommand(request.Email, request.Password); await _dispatcher.SendAsync(command); return(Ok()); }
public async Task <IActionResult> OnPostAsync() { if (!ModelState.IsValid) { Topics = await LoadTopics(); return(Page()); } var readCommand = new EntityIdentifierQuery <Guid, SignUpUpdateModel>(User, Id); var updateModel = await Mediator.Send(readCommand); if (updateModel == null) { return(NotFound()); } // only update input fields await TryUpdateModelAsync( updateModel, nameof(Entity), p => p.Name, p => p.Description ); var updateCommand = new SignUpCommand(User, Id, updateModel, SignUpTopics); var result = await Mediator.Send(updateCommand); ShowAlert("Successfully saved instructor signup"); return(RedirectToPage("/signup/View", new { id = Id, tenant = TenantRoute })); }
public async Task <Result <SignUpResult> > Handle(SignUpCommand request, CancellationToken cancellationToken) { try { var result = await _userService.SignUpAsync(request.UserName, request.Password); if (result.Succeeded) { return(Result <SignUpResult> .Success(new SignUpResult())); } Error error; if (result.Errors != null && result.Errors.Any()) { var identityError = result.Errors.First(); error = new Error(identityError.Code, identityError.Description); } else { error = Error.Default(); } return(Result <SignUpResult> .Fail(error)); } catch (Exception e) { _logger.LogError(e, e.Message); return(Result <SignUpResult> .Fail(Error.Default())); } }
public async Task <ApiRequestResult> AddAsync([FromBody] SignUpCommand command) { await _identityServices.SignUpAsync(command.Email, command.PhoneNumber, command.UserName, command.Password); return(ApiRequestResult.Success("添加成功")); }
public async Task <IActionResult> Post([FromBody] SignUpRequest request) { Picture picture = null; if (request.Picture != null) { picture = Picture.Create( request.Picture.Bytes, request.Picture.Size, request.Picture.Type, request.Picture.Name ); } SignUpCommand command = new SignUpCommand { Picture = picture, Name = request.Name, Email = request.Email, Password = request.Password }; SignUpResult result = await _useCase.Execute(command); return(Created(Request.Path, result)); }
private ICommand CreateSignUpCommand() { var command = new SignUpCommand( this.mainWindowViewModel, this.ninjectKernel.Get <IServerChatService>()); return(command); }
public async Task some_test() { var command = new SignUpCommand(); await _queuesManager.SendSignUpCommandAsync(command); _commandsSerializerMock.Received().SerializerMessage(Arg.Is(command)); //check the calls to whatever }
public async Task <IActionResult> Post([FromBody] SignUpCommand command) { var response = await apiGatewayService.SignUp(command); // technical debt - should be abstracted in the identity microservice, // this controller must not be concerned with business logic. return(response.Error ? BadRequest(response) : Ok(response)); }
public void can_serialize_valid_message() { var command = new SignUpCommand(); var result = _commandsSerializer.SerializerMessage(command); Assert.Equal(@"{""CourseId"":""00000000-0000-0000-0000-000000000000"",""User"":null}", result); }
public LoginVM() { User = new User(); _location = new Model.Location(); LoginCommand = new LoginCommand(this); SignUpCommand = new SignUpCommand(this); //LocationVM = new LocationVM(); //Called FIRST before location code behind }
public async Task <IActionResult> SignUp([FromBody] SignUpInputModel signUpInputModel) { var signUpCommand = new SignUpCommand(signUpInputModel); var signUpViewModel = await _mediator.Send(signUpCommand); return(CreatedAtAction(nameof(GetUserById), new { userId = signUpViewModel.UserId }, signUpViewModel)); }
public async Task <IActionResult> SignUp(SignUpCommand command) { command.BindId(c => c.Id); await _identityService.SignUpAsync(command.Id, command.Email, command.Password, command.Role); return(NoContent()); }
public MainPageVM() { try { User = new User(); Helpers.Data.User = new User(); mainPageCommand = new MainPageCommand(this); signUpCommand = new SignUpCommand(this); }catch (Exception ex) { App.Current.MainPage.DisplayAlert("Error", ex.Message, "OK"); } }
private Uri GetRequestUri <T>(SignUpCommand <T> command) { string requestUri = this.GetMessageBase <T>() + "/"; List <KeyValuePair <string, string> > queryStringParameters = new List <KeyValuePair <string, string> >(); queryStringParameters.AddRange(this.GetAdditionalParameters(command.AdditionalParameters)); queryStringParameters.ForEach(x => { requestUri = QueryHelpers.AddQueryString(requestUri, x.Key, x.Value); }); return(new Uri(requestUri, UriKind.Relative)); }
private void btRegistration_Click(object sender, EventArgs e) { var cmd = new SignUpCommand() { UserLogin = tbUserLogin.Text, UserPassword = tbUserPassword.Text }; Client.Execute(cmd); Client.UserLoginIn = tbUserLogin.Text; OnDialogResult(System.Windows.Forms.DialogResult.OK); MessageBox.Show("Registration Successfull!"); }
public async Task <IActionResult> SignUpAsync([FromBody] SignUpCommand command) { var authenticateDto = await _mediator.Send(command); if (authenticateDto == null) { return(BadRequest(new { error = "Email is already in use." })); } await _mediator.Publish(new UserCreatedEvent(authenticateDto.UserId)); return(Ok(authenticateDto)); }
public void Should_not_have_error(string username, string password) { var command = new SignUpCommand() { UserName = username, Password = password }; var validator = CreateValidator(); validator.ShouldNotHaveValidationErrorFor(x => x.UserName, command); validator.ShouldNotHaveValidationErrorFor(x => x.Password, command); }
public void SignUp_when_valid_password_does_not_throw() { var username = "******"; var password = "******"; var email = "*****@*****.**"; var command = new SignUpCommand(username, password, email); var mockEventBusService = new Mock <EventBusService>(Mock.Of <IEventBus>(), Mock.Of <IAppEventBuilder>()); var commandHandler = new SignUpCommandHandler(mockEventBusService.Object, Mock.Of <IUserAuthenticationDataRepository>(), Mock.Of <IUserRepository>(), Mock.Of <ILogger <SignUpCommandHandler> >()); Assert.DoesNotThrow(() => commandHandler.Handle(command, CancellationToken.None)); }
public void SetUp() { var user = new User(); var result = new SignUpResult { TokenCode = Test, User = user }; var emailTemplate = new EmailTemplate { TemplateName = Test, Subject = Test, Content = Test, AllowedParameters = new[] { "{{username}}", "{{callbackUrl}}" } }; request = new SignUpRequest(); authService = new Mock <IAuthService>(); serialService = new Mock <ISerialService>(); userService = new Mock <IReadOnlyUserService>(); emailSender = new Mock <IEmailSender>(); cryptoService = new Mock <ICryptoService>(); emailTemplateGenerator = new Mock <IEmailTemplateGenerator>(); authValidationService = new Mock <IAuthValidationService>(); captchaService = new Mock <ICaptchaService>(); mapper = new Mock <IMapper>(); configuration = new Mock <IConfiguration>(); authService.Setup(a => a.SignUp(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(result); captchaService.Setup(c => c.VerifyCaptcha(It.IsAny <string>())).ReturnsAsync(true); authValidationService.Setup(a => a.UsernameExists(It.IsAny <string>())).ReturnsAsync(false); authValidationService.Setup(a => a.EmailExists(It.IsAny <string>())).ReturnsAsync(false); serialService.Setup(s => s.SerialExists(It.IsAny <string>(), It.IsAny <int>())).ReturnsAsync(false); userService.Setup(u => u.FindUserByUsername(It.IsAny <string>())).ReturnsAsync(user); cryptoService.Setup(c => c.Encrypt(It.IsAny <string>())).Returns(Test); emailTemplateGenerator.Setup(etg => etg.FindEmailTemplate(It.IsAny <string>())) .ReturnsAsync(emailTemplate); emailSender.Setup(es => es.Send(It.IsAny <EmailMessage>())) .ReturnsAsync(true); configuration.Setup(c => c.GetSection(It.IsAny <string>())) .Returns(new Mock <IConfigurationSection>().Object); signUpCommand = new SignUpCommand(authService.Object, serialService.Object, userService.Object, emailSender.Object, cryptoService.Object, emailTemplateGenerator.Object, authValidationService.Object, captchaService.Object, configuration.Object, mapper.Object); }
public IActionResult SignUp([FromBody] SignUpInput input) { ApiResponse response; var command = new SignUpCommand(input.UserName, input.Password); var result = RabbitMq.Publish <SignUpCommand, Result <SignUpResult> >(command); if (!result.IsSucceeded) { response = new ApiResponse(result.Error.Code, result.Error.Description); return(BadRequest(response)); } response = new ApiResponse("OK", "Success"); return(Ok(response)); }
public async Task Should_Throws_Exception_Given_Existent_Email() { SignUpCommand command = new SignUpCommand { Email = "*****@*****.**", Name = "Jubileu antunes", Password = "******", Picture = null }; _userReadOnlyRepository .Setup(x => x.Any(command.Email)) .ReturnsAsync(true); await Assert.ThrowsAsync <UserEmailAlreadyExistsException>(() => signUpUseCase.Execute(command)); }