protected virtual void OnClientLogin(string Message, string userName)
 {
     ClientLogin?.Invoke(this, new ClientEventArgs()
     {
         clientLoginMessage = Message, clientLoginName = userName
     });
 }
        public async Task ClientLoginSucess()
        {
            var user = new Client()
            {
                Id       = 0,
                Name     = "user-test",
                Birthay  = new DateTime(2020, 05, 01),
                Cpf      = "test-registration",
                Password = "******"
            };
            await _repository.Add(user);

            Exception exception   = null;
            ClientJWT clientJWT   = null;
            var       clientLogin = new ClientLogin()
            {
                Password = user.Password,
                Cpf      = user.Cpf
            };

            try
            {
                clientJWT = await this._service.Login(clientLogin, new FakeAuthentication());
            }
            catch (UserNotDefinid ex)
            {
                exception = ex;
            }

            Assert.AreEqual(exception, null);
            Assert.AreEqual(clientJWT.Token, "token-implementation-fake");
        }
Exemplo n.º 3
0
        public ActionResult Register(RegistrationVM user)
        {
            if (ModelState.IsValid)
            {
                using (var context = new QuoteContext())
                {
                    //check database for existing username
                    if (context.ClientLogins.Any(x => x.Username == user.Username))
                    {
                        ModelState.AddModelError(string.Empty, "Username already exists");
                        return(View(user));
                    }
                    else
                    {
                        var newLogin = new ClientLogin();
                        newLogin.Username = user.Username;
                        newLogin.Password = user.Password;

                        var newClient = new Client();
                        newClient.ClientLogin = newLogin;


                        context.Clients.Add(newClient);
                        context.ClientLogins.Add(newLogin);
                        context.SaveChanges();

                        return(Redirect("/Account/Login"));
                    }
                }
            }

            //Redirect to Login Page if model state valid
            return(View());
        }
        public async Task NotLoginPasswordWrong()
        {
            var user = new Client()
            {
                Id       = 0,
                Name     = "user-test",
                Birthay  = new DateTime(2020, 05, 01),
                Cpf      = "test-registration",
                Password = "******"
            };
            await _repository.Add(user);

            Exception exception   = null;
            var       clientLogin = new ClientLogin()
            {
                Password = "******",
                Cpf      = user.Cpf
            };

            try
            {
                await this._service.Login(clientLogin, new FakeAuthentication());
            }
            catch (Exception ex)
            {
                exception = ex;
            }

            Assert.AreNotEqual(exception, null);
        }
Exemplo n.º 5
0
        public async Task <ActionResult <ClientLogin> > PostClientLogin(ClientLogin clientLogin)
        {
            _context.ClientLogin.Add(clientLogin);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetClientLogin", new { id = clientLogin.ID }, clientLogin));
        }
Exemplo n.º 6
0
        public async Task <IActionResult> PutClientLogin(int id, ClientLogin clientLogin)
        {
            if (id != clientLogin.ID)
            {
                return(BadRequest());
            }

            _context.Entry(clientLogin).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ClientLoginExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 7
0
        public ClientLogin GetClientByUsername(string username)
        {
            var reader = this.ExecuteReader(
                @"select
	                    c.Id,
	                    c.Username,
	                    c.PasswordHash,
	                    c.PasswordSalt,
	                    ct.Name as RoleName
                    from Clients as c
                    join ClientTypes as ct
                    on c.ClientTypeId = ct.Id
                    where Username = @username",
                new Dictionary <string, object> {
                { "@username", username }
            });
            ClientLogin client = null;

            using (reader)
            {
                for (int usersCount = 0; reader.Read() && usersCount <= 1; usersCount++)
                {
                    int    id = reader.GetInt32(0);
                    string usernameFromDatabase = reader.GetString(1);
                    string passwordHash         = reader.GetString(2);
                    string passwordSalt         = reader.GetString(3);
                    string roleName             = reader.GetString(4);
                    client = new ClientLogin(id, usernameFromDatabase, roleName, passwordHash, passwordSalt);
                }
            }

            return(client);
        }
Exemplo n.º 8
0
 public ProjectG(TcpClient tcp) : base(tcp)
 {
     ServerType      = ServerTypeEnum.Login;
     PacketLogin     = new ClientLogin();
     PacketGame      = new ClientGame();
     PacketMessenger = new ClientMessanger();
     Commands        = new ChatCommands();
 }
Exemplo n.º 9
0
    void Client_ConnectOkEvent()
    {
        Debug.Log("ConnectOk");
        ClientLogin model_login = new ClientLogin();

        model_login.UserName = "******";
        model_login.Password = "******";
        NetHelp.Send <ClientLogin>(Op.Client.Login, model_login, Connection.Client.socket);
    }
Exemplo n.º 10
0
    void Awake()
    {
        login = GameObject.Find("Login").GetComponent <ClientLogin>();
        string name = string.Format(ActionFormat(), "erew");
        var    type = System.Reflection.Assembly.GetCallingAssembly().GetType(name);

        Debug.Log(type);
        isLogin = false;
    }
Exemplo n.º 11
0
        public ActionResult ClientLogin(ClientLogin clientLogin)
        {
            //a client tries to login
            List <string> info   = new List <string>();
            List <string> errors = new List <string>();

            info.Add(inputsValidator.ValidateIDInput("ID", clientLogin.ID));
            info.Add(inputsValidator.ValidateYearOfBirthInput("Year Of Birth", clientLogin.YearOfBirth.ToString()));
            foreach (var item in info)
            {
                if (!string.IsNullOrEmpty(item))
                {
                    errors.Add(item);
                }
            }
            for (int i = 0; i < errors.Count; i++)
            {
                if (i == 0)
                {
                    ViewBag.Message1 = errors[0];
                }
                if (i == 1)
                {
                    ViewBag.Message2 = errors[1];
                }
            }
            if (errors.Count == 0)
            {
                Tuple <object, HttpStatusCode> returnTuple = httpClient.PostRequest(ApiConfigs.ClientLoginRoute, clientLogin);
                if (returnTuple.Item2 == HttpStatusCode.OK)
                {
                    JObject jobj = new JObject();
                    jobj = (JObject)returnTuple.Item1;
                    Client client = jobj.ToObject <Client>();
                    WebClientContainer.container.GetInstance <ISessionData>().updateLoggedInID(Convert.ToInt32(client.ID));
                    if (ClientHasLines(client))
                    {
                        return(RedirectToAction("ClientView", client));
                    }
                    else
                    {
                        ViewBag.ErrorMessage = "You dont own any lines yet";
                        return(View("Index"));
                    }
                }
                else
                {
                    ViewBag.ErrorMessage = returnTuple.Item2;
                    return(View("Index"));
                }
            }
            else
            {
                return(View("Index"));
            }
        }
 public ActionResult CreerCompte(ClientLogin client)
 {
     if (ModelState.IsValid)
     {
         int id = dal.AjouterClientRenvoiId(client.Nom, client.Prenom, client.Email, client.ConfirmEmail, client.Date_Naissance, client.Password, client.Telephone);
         FormsAuthentication.SetAuthCookie(id.ToString(), false);
         return(Redirect("/"));
     }
     return(View(client));
 }
 public async Task <ActionResult> Login([FromBody] ClientLogin user)
 {
     try
     {
         return(StatusCode(200, await _clientLogin.Login(user, new Authentication())));
     }
     catch (UserNotFound err)
     {
         return(StatusCode(401, new {
             Message = err.Message
         }));
     }
 }
 public ShoppingCartController(
     ClientLogin clientLogin,
     CookieShoppingCart cookieShoppingCart,
     IProductRepository productRepository,
     IDeliveryAddressRepository deliveryAddressRepository,
     IMapper mapper,
     WSCorreiosCalculateFreight wSCorreiosCalculateFreight,
     CalculatePackage calculatePackage,
     CookieFreight cookieFreight
     )
     : base(clientLogin, cookieShoppingCart, productRepository, deliveryAddressRepository, mapper, wSCorreiosCalculateFreight, calculatePackage, cookieFreight)
 {
 }
Exemplo n.º 15
0
        public ActionResult AdminPanel([Bind(Include = "Login,MotDePasse")] ClientLogin c)
        {
            if (ModelState.IsValid)
            {
                if (c.Login == "admin" && c.MotDePasse == "admin")
                {
                    return(RedirectToAction("Index", "Categories"));
                }
            }

            ViewData["erreurAuth"] = "erreurAuth";
            return(View("Index"));
        }
Exemplo n.º 16
0
        /// <summary>
        /// Initializes the service before MakeApiCall.
        /// </summary>
        /// <param name="methodName">Name of the method.</param>
        /// <param name="parameters">The method parameters.</param>
        protected override void InitForCall(string methodName, object[] parameters)
        {
            DfpAppConfig  config      = this.User.Config as DfpAppConfig;
            string        oAuthHeader = null;
            RequestHeader header      = GetRequestHeader();

            if (header == null)
            {
                throw new DfpApiException(null, DfpErrorMessages.FailedToSetAuthorizationHeader);
            }

            if (!(this.GetType().Name == "NetworkService" && (methodName == "getAllNetworks" ||
                                                              methodName == "makeTestNetwork")))
            {
                if (string.IsNullOrEmpty(header.networkCode))
                {
                    throw new SoapHeaderException("networkCode header is required in all API versions. " +
                                                  "The only exceptions are NetworkService.getAllNetworks and " +
                                                  "NetworkService.makeTestNetwork.", XmlQualifiedName.Empty);
                }
            }

            if (string.IsNullOrEmpty(header.applicationName) || header.applicationName.Contains(
                    DfpAppConfig.DEFAULT_APPLICATION_NAME))
            {
                throw new ApplicationException(DfpErrorMessages.RequireValidApplicationName);
            }

            if (config.AuthorizationMethod == DfpAuthorizationMethod.OAuth2)
            {
                if (this.User.OAuthProvider != null)
                {
                    oAuthHeader = this.User.OAuthProvider.GetAuthHeader();
                }
                else
                {
                    throw new DfpApiException(null, DfpErrorMessages.OAuthProviderCannotBeNull);
                }
            }
            else if (config.AuthorizationMethod == DfpAuthorizationMethod.ClientLogin)
            {
                string authToken = (!string.IsNullOrEmpty(config.AuthToken)) ? config.AuthToken :
                                   new AuthToken(config, SERVICE_NAME).GetToken();
                ClientLogin clientLogin = (header.authentication as ClientLogin) ?? new ClientLogin();
                clientLogin.token     = authToken;
                header.authentication = clientLogin;
            }

            ContextStore.AddKey("OAuthHeader", oAuthHeader);
            base.InitForCall(methodName, parameters);
        }
Exemplo n.º 17
0
        public Client ClientLogin(ClientLogin clientLogin)
        {
            //tries a client login, returns null if info is unvalid
            Client client = networkRepository.GetClientByID(clientLogin.ID);

            if (client != null)
            {
                if (client.BirthDate.Year == clientLogin.YearOfBirth)
                {
                    return(client);
                }
            }
            return(null);
        }
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            _clientLogin = (ClientLogin)context.HttpContext.RequestServices.GetService(typeof(ClientLogin));
            Client client = _clientLogin.GetClient();

            if (client == null)
            {
                //TODO - Implementar tela melhor construída -> Acesso Negado/ status 400/ 4XX ...
                context.Result = new ContentResult()
                {
                    Content = "Acesso negado!"
                };
            }
        }
Exemplo n.º 19
0
        public void OnAuthorization(AuthorizationFilterContext context)
        {
            _clientLogin = (ClientLogin)context.HttpContext.RequestServices.GetService(typeof(ClientLogin));

            Client client = _clientLogin.GetClient();

            if (client == null)
            {
                context.Result = new ContentResult()
                {
                    Content = "Acesso negado via filtros"
                };
            }
        }
Exemplo n.º 20
0
 public IHttpActionResult LoginClient(ClientLogin login)
 {
     try
     {
         //Generate token
         var token = TokenManager.GenerateToken(login.PhoneNumber);
         login.Token = token;
         return(Ok(manager.LoginClient(login)));
     }
     catch (Exception ex)
     {
         GlobalVariable.log.Write(LogLevel.Error, ex);
         return(InternalServerError());
     }
 }
Exemplo n.º 21
0
        public IHttpActionResult ClientWebLogin([FromBody] ClientLogin clientLogin)
        {
            //tries a client login from the web service

            Client client = accountsManager.ClientLogin(clientLogin);

            if (client != null)
            {
                return(Ok(client));
            }
            else
            {
                return(Conflict());
            }
        }
        public async Task <ClientJWT> Login(ClientLogin user, IToken token)
        {
            var loggedUser = await _repository.FindByCpfAndPassword(user.Cpf, user.Password);

            if (loggedUser == null)
            {
                throw new UserNotFound("Usuário ou senha inválidos.");
            }
            return(new ClientJWT()
            {
                Id = loggedUser.Id,
                Name = loggedUser.Name,
                Cpf = loggedUser.Cpf,
                Role = loggedUser.UserRole.ToString(),
                Token = token.TokenGenerateClient(loggedUser)
            });
        }
 /// <summary>
 /// Loads wiki article from the internet
 /// </summary>
 /// <param name="articleName"></param>
 public void LoadWikiArticle(string articleName)
 {
     if (loggedinUser == null)
     {
         loggedinUser = new ClientLogin();
         loggedinUser.ShowDialog();
     }
     if (loggedinUser.IsAuthenticated)
     {
         this.richTextBoxHindi.Text   = loggedinUser.LogOnBot.GetContent(articleName);
         this.SetOnlineArticleName    = articleName;
         this.SetEditingOnLineArticle = true;
     }
     else
     {
         SetEditingOnLineArticle = false;
         loggedinUser.ShowDialog();
     }
 }
Exemplo n.º 24
0
        public Context(Application application, Config config, TimeSync ts)
        {
            _application = application;
            _config      = config;
            _ts          = ts;
            _sharpc      = new Maria.Sharp.SharpC();
            _dispatcher  = new EventDispatcher(this);

            _login                = new ClientLogin(this);
            _login.OnLogined      = OnLoginAuthed;
            _login.OnConnected    = OnLoginConnected;
            _login.OnDisconnected = OnLoginDisconnected;

            _client                = new ClientSocket(this, _config.s2c, _config.c2s);
            _client.OnAuthed       = OnGateAuthed;
            _client.OnConnected    = OnGateConnected;
            _client.OnDisconnected = OnGateDisconnected;
            _client.OnRecvUdp      = OnUdpRecv;
        }
        public async Task NotLoginUserNotExist()
        {
            var clientLogin = new ClientLogin()
            {
                Password = "******",
                Cpf      = "not-exist"
            };
            Exception exception = null;

            try{
                await this._service.Login(clientLogin, new FakeAuthentication());
            }catch (Exception ex)
            {
                exception = ex;
            }


            Assert.AreNotEqual(exception, null);
        }
Exemplo n.º 26
0
 public BaseController(
     ClientLogin clientLogin,
     CookieShoppingCart cookieShoppingCart,
     IProductRepository productRepository,
     IDeliveryAddressRepository deliveryAddressRepository,
     IMapper mapper,
     WSCorreiosCalculateFreight wSCorreiosCalculateFreight,
     CalculatePackage calculatePackage,
     CookieFreight cookieFreight)
 {
     _clientLogin                = clientLogin;
     _cookieShoppingCart         = cookieShoppingCart;
     _productRepository          = productRepository;
     _mapper                     = mapper;
     _wSCorreiosCalculateFreight = wSCorreiosCalculateFreight;
     _calculatePackage           = calculatePackage;
     _cookieFreight              = cookieFreight;
     _deliveryAddressRepository  = deliveryAddressRepository;
 }
Exemplo n.º 27
0
        public async Task <ClientLogin> TestCreateHydratedCard()
        {
            try {
                CardsavrHelper helper = new CardsavrHelper();
                helper.SetAppSettings("https://api.<SERVERR>.cardsavr.io/", "<INTEGRATOR NAME>", "<INTEGRATOR KEY>", false);
                ClientSession auth = await helper.LoginAndCreateSession("<USERNAME>", "<PASSWORD>", "{\"key\": \"my_trace\"}");

                PropertyBag cd = new PropertyBag()
                {
                    { "my_fi", new PropertyBag()
                      {
                          { "token", "123" }
                      } }
                };
                ClientLogin login = await helper.CreateCard("testing_user",
                                                            new Cardholder()
                {
                    email = "*****@*****.**", custom_data = cd, cuid = "12345"
                },
                                                            new Card()
                {
                    pan = "4111111111111111", cvv = "111", expiration_month = "01", expiration_year = "25"
                },
                                                            new Address()
                {
                    first_name = "Strivve", last_name = "User", is_primary = true, phone_number = "5555555555", address1 = "1234 1st ave", city = "Seattle", subnational = "WA", postal_code = "98006", country = "USA"
                }
                                                            );

                await helper.CloseSession("AdvAppUser");

                Console.WriteLine("CARDSAVRHELPERTESTS cuid: " + login.cardholder.cuid + ", grant: " + login.grant + ", card_id: " + login.card.id);

                return(login);
            } catch (Exception e) {
                Console.Write(e);
            }
            return(null);
        }
Exemplo n.º 28
0
        public async void TestCreateHydratedCard()
        {
            CardsavrSession.InstanceConfig config = this.session.getConfig();
            CardsavrHelper helper = new CardsavrHelper();

            helper.SetAppSettings(config.cardsavr_server, config.app_name, config.app_key, CardsavrSession.rejectUnauthorized);
            await helper.LoginAndCreateSession(config.app_username, config.app_password, "{\"key\": \"my_trace\"}");

            PropertyBag cd = new PropertyBag()
            {
                { "my_fi", new PropertyBag()
                  {
                      { "token", "123" }
                  } }
            };
            string      cuid  = $"{CardsavrSession.e2e_identifier}_{CardsavrSession.random.Next(10000)}_0";
            ClientLogin login = await helper.CreateCard(config.app_username,
                                                        new Cardholder()
            {
                custom_data = cd, cuid = cuid
            },
                                                        new Card()
            {
                pan = "4111111111111111", cvv = "111", expiration_month = "01", expiration_year = "25"
            },
                                                        new Address()
            {
                first_name = "Strivve", last_name = "User", email = "*****@*****.**", is_primary = true, phone_number = "5555555555", address1 = "1234 1st ave", city = "Seattle", subnational = "WA", postal_code = "98006", country = "USA"
            }
                                                        );

            await helper.CloseSession(config.app_username);

            Assert.NotNull(login.cardholder.grant);
            Assert.Equal(login.cardholder.cuid, cuid);
            Assert.True(login.card.id > 0);
            log.Info("CARDSAVRHELPERTESTS cuid: " + login.cardholder.cuid + ", grant: " + login.grant + ", card_id: " + login.card.id);
            //login can now be used as a redirect to a url that can log in and process jobs
        }
Exemplo n.º 29
0
        private void welcomeUsersToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (loggedinUser == null)
            {
                loggedinUser = new ClientLogin();
                loggedinUser.ShowDialog();
            }

            List <string> newUsersToWelcome = new List <string>();

            if (loggedinUser.IsAuthenticated)
            {
                newUsersToWelcome = loggedinUser.LogOnBot.WelcomeNewUsers();
            }

            var stringBuilder = new StringBuilder();

            foreach (string User in newUsersToWelcome)
            {
                stringBuilder.AppendLine("Welcome : " + User);
            }
            richTextBoxNepali.Text = stringBuilder.ToString();
        }
Exemplo n.º 30
0
        private void speedyDeleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            List <string> articlesListConfirmedForDeletion = new List <string>();

            if (loggedinUser == null)
            {
                loggedinUser = new ClientLogin();
                loggedinUser.ShowDialog();
            }



            List <string> articlesToDelete = loggedinUser.LogOnBot.GetArticleForSpeedyDeletion("Delete");

            foreach (string articleMarkedForDeletion in articlesToDelete)
            {
                var DeleteOrNot = MessageBox.Show("Delete" + articleMarkedForDeletion, "Delete confirm", MessageBoxButtons.OKCancel);
                if (DeleteOrNot == DialogResult.OK)
                {
                    articlesListConfirmedForDeletion.Add(articleMarkedForDeletion);
                }
            }
            loggedinUser.LogOnBot.DeleteConfirmed(articlesListConfirmedForDeletion);
        }