Esempio n. 1
0
        public SignInViewModel(IUnityContainer container) : base(container)
        {
            _nonAuthenticationApi = Container.Resolve <INonAuthenticationApi>();
            ConfigureFile         = Container.Resolve <IConfigureFile>();
            SignInCommand         = new RelayCommand <PasswordBox>(SignInCommandExecute, passwordBox => CanSignIn(Email, passwordBox.Password));

            EventAggregator.GetEvent <SignUpSuccessEvent>().Subscribe(signUpArgs => _signUpArgs = signUpArgs);
        }
Esempio n. 2
0
        public async Task <SignInApiResponse> SignUp(SignUpArgs args)
        {
            var response = new SignInApiResponse {
                Lang = Language
            };

            if (args == null)
            {
                response.Error = "json parameters are empty";
                return(response);
            }

            if (string.IsNullOrWhiteSpace(args.Email))
            {
                response.Error = BshkaraRes.Api_Auth_EmailIsEmpty;
                return(response);
            }

            if (!args.Email.IsValidEmail())
            {
                response.Error = BshkaraRes.Api_Auth_EmailIsNotValid;
                return(response);
            }

            if (string.IsNullOrWhiteSpace(args.Password))
            {
                response.Error = BshkaraRes.Api_Auth_PasswordIsEmpty;
                return(response);
            }

            if (string.IsNullOrWhiteSpace(args.ConfirmedPassword))
            {
                response.Error = BshkaraRes.Api_Auth_ConfirmatedPasswordEmpty;
                return(response);
            }

            if (args.Password != args.ConfirmedPassword)
            {
                response.Error = BshkaraRes.Api_Auth_PasswordNotEqualsConfirmatedPassword;
                return(response);
            }

            var user = new UserEntity {
                UserName = args.UserName, Email = args.Email
            };
            var result = await UserManager.CreateAsync(user, args.Password);

            if (result.Succeeded)
            {
                return(await SignInAsync(new SignInArgs { Email = user.Email, Password = args.Password }));
            }

            response.Error = BshkaraRes.Api_Auth_CantCreateUser;

            return(response);
        }
Esempio n. 3
0
        public async Task <SignInApiResponse> AuthSignUp(SignUpArgs args)
        {
            return(await TryInvoceAsync <SignInApiResponse>(async() =>
            {
                var httpClient = GetHttpClientWidthAuthenticationHeader();
                var content = new StringContent(JsonConvert.SerializeObject(args), Encoding.UTF8, "application/json");

                return await httpClient.PostAsync("auth/signup", content);
            }));
        }
Esempio n. 4
0
 public async Task <string> SignUp([FromBody] SignUpArgs args)
 {
     return(await this.AccountUseCase.SignUpAsync(args));
 }
Esempio n. 5
0
 public async Task <SignInApiResponse> SignUpAsync(SignUpArgs args)
 {
     return(await _apiClient.AuthSignUp(args));
 }