Exemple #1
0
        public AccountLoginPageViewModel(DiscordContext discordContext, INavigationService navService)
        {
            _DiscordContext    = discordContext;
            _NavigationService = navService;

            Mail               = new ReactiveProperty <string>("");
            Password           = new ReactiveProperty <string>("");
            IsRememberPassword = new ReactiveProperty <bool>(false);

            TryLoginCommand = Observable.CombineLatest(
                Mail.Select(x => !string.IsNullOrEmpty(x)), /* TODO: check with regex */
                Password.Select(x => !string.IsNullOrWhiteSpace(x))
                )
                              .Select(x => x.All(y => y))
                              .ToReactiveCommand();

            NowTryLogin = new ReactiveProperty <bool>(false);

            TryLoginCommand.Subscribe(async _ => await TryLogin(Mail.Value, Password.Value, IsRememberPassword.Value));

            if (_DiscordContext.TryGetRecentLoginAccount(out var mailAndPassword))
            {
                Mail.Value               = mailAndPassword.Item1;
                Password.Value           = mailAndPassword.Item2;
                IsRememberPassword.Value = true;
            }

            IsFailedLogin  = new ReactiveProperty <bool>();
            IsLoginSuccess = new ReactiveProperty <bool>();
        }
Exemple #2
0
 public TryLoginCommandHandlerTest()
 {
     userManager    = CustomMock.GetMockUserManager();
     signInManager  = CustomMock.GetMockSignInManager();
     tokenService   = new Mock <ITokenService>();
     bus            = new Mock <IBus>();
     command        = new TryLoginCommand();
     commandHandler = new TryLoginCommandHandler(userManager.Object, signInManager.Object, tokenService.Object, bus.Object);
     user           = new User();
     tokenModel     = new TokenModel(It.IsAny <string>(), It.IsAny <string>());
 }
Exemple #3
0
        // TODO: ログインエラー時のテキスト表示

        public LoginPageViewModel(
            ApplicationLayoutManager applicationLayoutManager,
            PageManager pageManager,
            NiconicoSession niconicoSession
            )
        {
            PageManager     = pageManager;
            NiconicoSession = niconicoSession;

            var version = Windows.ApplicationModel.Package.Current.Id.Version;

            VersionText = $"{version.Major}.{version.Minor}.{version.Build}";

            Mail     = new ReactiveProperty <string>("", mode: ReactivePropertyMode.DistinctUntilChanged);
            Password = new ReactiveProperty <string>("", mode: ReactivePropertyMode.DistinctUntilChanged);

            IsRememberPassword = new ReactiveProperty <bool>(!string.IsNullOrEmpty(Password.Value));

            IsValidAccount        = new ReactiveProperty <bool>(NiconicoSession.IsLoggedIn);
            NowProcessLoggedIn    = new ReactiveProperty <bool>(false);
            IsAuthoricationFailed = new ReactiveProperty <bool>(false);
            IsServiceUnavailable  = new ReactiveProperty <bool>(false);

            // メールかパスワードが変更されたらログイン検証されていないアカウントとしてマーク
            TryLoginCommand = Observable.CombineLatest(
                Mail.Select(x => !string.IsNullOrWhiteSpace(x)),
                Password.Select(x => !string.IsNullOrWhiteSpace(x)),
                NowProcessLoggedIn.Select(x => !x)
                )
                              .Select(x => x.All(y => y))
                              .ToReactiveCommand();

            TryLoginCommand.Subscribe(async _ =>
            {
                NowProcessLoggedIn.Value = true;

                try
                {
                    await TryLogin();
                }
                finally
                {
                    NowProcessLoggedIn.Value = false;
                }
            });
        }
Exemple #4
0
 public async Task <IActionResult> Login(TryLoginCommand command)
 {
     return(Ok(await mediator.Send(command)));
 }
 public LoginViewModel()
 {
     Login                   = new Login();
     TryLoginCommand         = new TryLoginCommand(this);
     GetFastLoginDataCommand = new GetFastLoginDataCommand(this);
 }