コード例 #1
0
        public AuthorizationResult Authorize()
        {
            var dlg = new AuthenticationView();

            dlg.webBrowser.Navigate(
                CreateAuthorizeUrl(_authParams.ApplicationId, _authParams.Settings.ToUInt64(), Display.Mobile, "123456"));

            dlg.webBrowser.Navigated += (sender, args) =>
            {
                var result = VkAuthorization.From(args.Uri.AbsoluteUri);

                if (!result.IsAuthorized)
                {
                    return;
                }

                dlg.Auth = new AuthorizationResult
                {
                    AccessToken = result.AccessToken,
                    ExpiresIn   = result.ExpiresIn,
                    UserId      = result.UserId,
                    State       = result.State
                };

                dlg.Close();
            };

            dlg.ShowDialog();

            return(dlg.Auth);
        }
コード例 #2
0
        public AuthorizationResult Validate(string validateUrl, string phoneNumber)
        {
            var dlg = new AuthenticationView();

            dlg.webBrowser.Navigate(validateUrl);

            dlg.webBrowser.Navigated += (sender, args) =>
            {
                var result = VkAuthorization.From(args.Uri.AbsoluteUri);

                if (!result.IsAuthorized)
                {
                    return;
                }

                dlg.Auth = new AuthorizationResult
                {
                    AccessToken = result.AccessToken,
                    ExpiresIn   = result.ExpiresIn,
                    UserId      = result.UserId,
                    State       = result.State
                };

                dlg.Close();
            };

            dlg.ShowDialog();

            return(dlg.Auth);
        }
コード例 #3
0
        static void Main()
        {
            userService    = new UserService();
            messageService = new MessageService();
            friendService  = new FriendService(userService);

            mainView                 = new MainView();
            registrationView         = new RegistrationView(userService);
            authenticationView       = new AuthenticationView(userService);
            userMenuView             = new UserMenuView();
            userInfoView             = new UserInfoView();
            userDataUpdateView       = new UserDataUpdateView(userService);
            messageSendingView       = new MessageSendingView(messageService, userService);
            userIncomingMessageView  = new UserIncomingMessageView();
            userOutcomingMessageView = new UserOutcomingMessageView();

            friendManageView = new FriendsManageView();
            addFriendView    = new AddFriendView(userService, friendService);
            showFriendView   = new ShowFriendsView(friendService);

            while (true)
            {
                mainView.Show();
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            Console.OutputEncoding = Encoding.UTF8;
            Console.InputEncoding  = Encoding.Unicode;

            userService    = new UserService();
            messageService = new MessageService();
            friendService  = new FriendService();

            mainView                 = new MainView();
            registrationView         = new RegistrationView(userService);
            authenticationView       = new AuthenticationView(userService);
            userMenuView             = new UserMenuView(userService);
            userInfoView             = new UserInfoView();
            userDataUpdateView       = new UserDataUpdateView(userService);
            messageSendingView       = new MessageSendingView(messageService, userService);
            userIncomingMessageView  = new UserIncomingMessageView();
            userOutcomingMessageView = new UserOutcomingMessageView();
            friendCreateNewView      = new FriendCreateView(friendService);

            while (true)
            {
                mainView.Show();
            }
        }
コード例 #5
0
        public MainWindow()
        {
            InitializeComponent();

            var authenticator = new AuthenticationView(this);
            var mainView      = MainView.Create(authenticator);

            DataContext = mainView;

            Loaded += (sender, e) =>
            {
                mainView.Start();
            };
        }
コード例 #6
0
        public IActionResult Post([FromBody] AuthenticationView value)
        {
            AuthenticationView view = null;

            try
            {
                view = authenticationApplicationService.SignIn(value);
            }
            catch (Exception ex)
            {
                return(BadRequest(ex.Message));
            }
            return(Ok(view));
        }
コード例 #7
0
        private VATRP.Core.Model.VATRPCredential GetAuthentication()
        {
            AuthenticationView _authForm = new AuthenticationView();

            _authForm.ShowDialog();
            if (!_authForm.Proceed)
            {
                return(null);
            }
            VATRPCredential tempCred = new VATRPCredential();

            tempCred.username = _authForm.Username;
            tempCred.password = _authForm.Password;
            return(tempCred);
        }
コード例 #8
0
        public IActionResult Authenticate([FromBody] AuthenticationView authenticationView)
        {
            try
            {
                var user = userService.Authenticate(authenticationView.Username, authenticationView.Password);

                // jwt config
                var tokenHandler = new JwtSecurityTokenHandler();
                var key          = Encoding.ASCII.GetBytes(appSettings.Secret);

                var tokenDescriptor = new SecurityTokenDescriptor
                {
                    Subject = new ClaimsIdentity(new Claim[]
                    {
                        new Claim(ClaimTypes.Name, user.UserId.ToString()),
                        new Claim(ClaimTypes.Role, user.Role)
                    }),
                    Expires            = DateTime.UtcNow.AddDays(7),
                    SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha256Signature)
                };

                var token       = tokenHandler.CreateToken(tokenDescriptor);
                var tokenString = tokenHandler.WriteToken(token);

                // return basic user info and token to store client side
                return(Ok(new
                {
                    user.UserId,
                    user.Username,
                    user.RegistrationDate,
                    user.Role,
                    Token = tokenString
                }));
            }
            catch (ArgumentException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (NotFoundInDbException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                // Internal Server Error
                return(StatusCode(500, ex.Message));
            }
        }
コード例 #9
0
        public void ShowAuthentication()
        {
            this.StopLoading();

            this.EnableCommand(false, this._service, Guids.COMMAND_REFRESH_ID);
            this.EnableCommand(false, this._service, Guids.COMMAND_HOME_ID);
            this.EnableCommand(false, this._service, Guids.COMMAND_FILTERS_ID);
            this.EnableCommand(false, this._service, Guids.COMMAND_ADVANCED_SEARCH_ID);
            this.EnableCommand(false, this._service, Guids.COMMAND_CONNECTION_ID);

            this._historyNavigator.ClearStack();

            this._authenticationView = new AuthenticationView(this, this._oAuthService, this._basicAuthenticationService, this._userService);

            SelectedView = this._authenticationView;
        }
コード例 #10
0
        public void PostTest_Fail()
        {
            var view = new AuthenticationView()
            {
                Username = "",
                Password = ""
            };
            Mock <IAuthenticationApplicationService> appServiceMock = new Mock <IAuthenticationApplicationService>();

            appServiceMock.Setup(x => x.SignIn(It.IsAny <AuthenticationView>()))
            .Throws(new ArgumentException());
            AuthenticationController controller = new AuthenticationController(appServiceMock.Object);
            var result = controller.Post(view);

            Assert.NotNull(result);
            Assert.IsType <BadRequestObjectResult>(result);
        }
コード例 #11
0
        static void Main()
        {
            AuthenticationView authenticate = new AuthenticationView();

            authenticate.Authenticate();

            if (AuthenticationService.LogUser.IsAdmin)
            {
                AdminView admin = new AdminView();
                admin.View();
            }
            else
            {
                UserView user = new UserView();
                user.View();
            }
        }
コード例 #12
0
        public void PostTest_Success()
        {
            var view = new AuthenticationView()
            {
                Username = "******",
                Password = "******"
            };
            Mock <IAuthenticationApplicationService> appServiceMock = new Mock <IAuthenticationApplicationService>();

            appServiceMock.Setup(x => x.SignIn(It.IsAny <AuthenticationView>()))
            .Returns(new AuthenticationView());
            AuthenticationController controller = new AuthenticationController(appServiceMock.Object);
            var result = controller.Post(view);


            Assert.NotNull(result);
            Assert.IsType <OkObjectResult>(result);
        }
コード例 #13
0
        static void Main(string[] args)
        {
            userService    = new UserService();
            messageService = new MessageService();

            mainView                 = new MainView();
            registrationView         = new RegistrationView(userService);
            authenticationView       = new AuthenticationView(userService);
            userMenuView             = new UserMenuView(userService);
            userInfoView             = new UserInfoView();
            userDataUpdateView       = new UserDataUpdateView(userService);
            messageSendingView       = new MessageSendingView(messageService, userService);
            userIncomingMessageView  = new UserIncomingMessageView();
            userOutcomingMessageView = new UserOutcomingMessageView();

            while (true)
            {
                mainView.Show();
            }
        }
コード例 #14
0
        internal static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var applicationContext = new ApplicationContext();

            var source              = new XMLService();
            var loginService        = new LoginService(source);
            var registrationService = new RegistrationService(loginService, source);
            var mainService         = new UserListService(source);

            var authenticationView = new AuthenticationView(applicationContext);
            var registrationView   = new RegistrationView(applicationContext);
            var mainView           = new MainView(applicationContext);

            var mainPresenter           = new MainPresenter(mainView, mainService);
            var registrationPresenter   = new RegistrationPresenter(registrationView, registrationService);
            var authenticationPresenter = new AuthenticationPresenter(loginService, authenticationView, mainPresenter, registrationPresenter);

            authenticationPresenter.Run();
        }
コード例 #15
0
        /// <summary>
        /// The main entry point for the application
        /// </summary>
        public async Task LaunchBot()
        {
            CultureInfo.DefaultThreadCurrentCulture   = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.InvariantCulture;

            if (!Injected)
            {
                await CheckAndInject();

                Environment.Exit(0);
            }
            else
            {
                "Injected!!".Log(Logs.Injected);

                AppDomain.CurrentDomain.UnhandledException += (sender, args) =>
                {
                    MessageBox.Show("A exception occured! The details were logged");
                    args.ExceptionObject.ToString().Log(Logs.Exceptions, false);
                };
                AppDomain.CurrentDomain.AssemblyResolve += DependencyLoader.CurrentDomain_AssemblyResolve;
#if DEBUG
                Debugger.Launch();
                WinImports.AllocConsole();
                DebugAssist.Init();
#endif
                await SetRealmlist();

                try
                {
                    $"Enabling the login block until the user authenticates".Log(Logs.Injected, true);
                    LoginBlock.Enable();

                    Current.ShutdownMode = ShutdownMode.OnExplicitShutdown;
                    $"Bringing up the login window".Log(Logs.Injected, true);
                    var authenticationView = new AuthenticationView();
                    authenticationView.ShowDialog();
                    var authenticationModel = (AuthenticationViewModel)authenticationView.DataContext;
                    if (authenticationModel.Result == null || authenticationModel.Result.Value != DialogResult.OK)
                    {
                        Environment.Exit(0);
                    }

                    $"Initialising the bot".Log(Logs.Injected, true);
                    Memory.Init();

                    $"Disabling the login block".Log(Logs.Injected, true);
                    LoginBlock.Disable();

                    $"Showing the bots mainwindow".Log(Logs.Injected, true);
                    var mainView = new MainView();
                    Current.MainWindow = mainView;
                    mainView.Closed   += (sender, args) => { Environment.Exit(0); };
                    mainView.Show();
                }
                catch (Exception e)
                {
                    e.ToString().Log(Logs.Exceptions);
                }
            }
        }
コード例 #16
0
 public App()
 {
     InitializeComponent();
     MainPage = new AuthenticationView();
     ApiHelper.InitializeClient();
 }