public JsonResult getUserAuth(string page, string pageSize)
        {
            List <UserAuth> userAuths = UserAuthService.LoadEntities(u => true).ToList();

            int pageInt     = Convert.ToInt32(page);
            int pageSizeInt = Convert.ToInt32(pageSize);

            List <UserAuthEntity> users = new List <UserAuthEntity>();

            foreach (UserAuth item in userAuths)
            {
                users.Add(new UserAuthEntity {
                    username = UserService.LoadEntities(u => u.uid == item.uid).FirstOrDefault().username,
                    main     = item.main,
                    house    = item.house,
                    users    = item.users,
                    orders   = item.orders,
                    others   = item.others,
                    uid      = item.uid,
                    uaid     = item.uaid,
                    house123 = item.main
                });
            }

            int total = users.Count;

            users = users.Skip((pageInt - 1) * pageSizeInt).Take(pageSizeInt).ToList();

            return(Json(new { users = users, total = total }, JsonRequestBehavior.AllowGet));
        }
Beispiel #2
0
        internal SshService RegisterService(string serviceName, UserAuthArgs auth = null)
        {
            Contract.Requires(serviceName != null);

            SshService service = null;

            switch (serviceName)
            {
            case "ssh-userauth":
                if (GetService <UserAuthService>() == null)
                {
                    service = new UserAuthService(this);
                }
                break;

            case "ssh-connection":
                if (auth != null && GetService <ConnectionService>() == null)
                {
                    service = new ConnectionService(this, auth);
                }
                break;
            }
            if (service != null)
            {
                ServiceRegistered?.Invoke(this, service);

                _services.Add(service);
            }
            return(service);
        }
        public JsonResult addUser(UserUserInfoEntity entity)
        {
            User user = UserService.AddEntity(new User {
                username = entity.username,
                password = entity.password,
                isSys    = entity.isSys
            });

            if (entity.isSys == "1")
            {
                UserAuthService.AddEntity(new UserAuth {
                    main = "0", users = "0", orders = "0", house = "0", others = "0", uid = user.uid
                });
            }

            UserInfo userInfo = UserInfoService.AddEntity(new UserInfo {
                name  = entity.name,
                sex   = entity.sex,
                phone = entity.phone
            });

            UserUserInfoService.AddEntity(new UserUserInfo {
                uid     = user.uid,
                uiid    = userInfo.uiid,
                pubTime = DateTime.Now.ToString("yyyyMMdd")
            });

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Beispiel #4
0
 private void initUserComponent()
 {
     if (!UserAuthService.isArtist())
     {
         artistesToolStripMenuItem.Visible = false;
     }
 }
Beispiel #5
0
        private void btn_order_Click(object sender, EventArgs e)
        {
            if (dtg_basket.Rows.Count <= 0)
            {
                MessageBox.Show("Le panier est vide !");
                return;
            }

            this.sLA_ORDERSTableAdapter.InsertQuery(1, UserAuthService.getUserId());
            int id = int.Parse(this.sLA_ORDERSTableAdapter.LastInsertedIdQuery().ToString());

            SlaDataSetTableAdapters.QueriesTableAdapter queriesTableAdapter = new SlaDataSetTableAdapters.QueriesTableAdapter();

            foreach (DataGridViewRow product in dtg_basket.Rows)
            {
                this.sLA_ORDER_PRODUCTSTableAdapter.InsertQuery(id, int.Parse(product.Cells[0].Value.ToString()), int.Parse(product.Cells[3].Value.ToString()));
                decimal?isValid = queriesTableAdapter.PKG_ORDER_UPDATEQUANTITY(int.Parse(product.Cells[0].Value.ToString()), id);
                if (isValid != null && isValid <= 0)
                {
                    MessageBox.Show("Quantité insuffissante pour le produit " + product.Cells[1].Value.ToString() + "!");
                    return;
                }
            }


            MessageBox.Show("Votre commande a bien été enregistré !");
        }
Beispiel #6
0
        private void fv_orders_Load(object sender, EventArgs e)
        {
            // TODO: cette ligne de code charge les données dans la table 'slaDataSet.SLA_ORDERS'. Vous pouvez la déplacer ou la supprimer selon les besoins.
            this.sLA_ORDERSTableAdapter.FillByUser(this.slaDataSet.SLA_ORDERS, UserAuthService.getUserId());


            // TODO: cette ligne de code charge les données dans la table 'slaDataSet.VW_ORDERS'. Vous pouvez la déplacer ou la supprimer selon les besoins.
        }
Beispiel #7
0
        private void btn_signup_Click(object sender, EventArgs e)
        {
            lbl_error_msg.Text = "";

            if (txt_email.TextLength < 1 || txt_password.TextLength < 1 || txt_username.TextLength < 1)
            {
                lbl_error_msg.Text = "Tous les champs sont obligatoires !";
            }

            if (UserAuthService.userExist(txt_email.Text, txt_username.Text))
            {
                lbl_error_msg.Text = "Veuillez indiquer un autre email ou nom d'utilisateur !";
            }

            try
            {
                SlaDataSet dataSet = new SlaDataSet();
                SlaDataSetTableAdapters.SLA_USERSTableAdapter usersTableAdapter = new SlaDataSetTableAdapters.SLA_USERSTableAdapter();
                // Create a new row.
                SlaDataSet.SLA_USERSRow usersRow;
                usersRow = dataSet.SLA_USERS.NewSLA_USERSRow();


                usersRow.USR_EMAIL    = txt_email.Text;
                usersRow.USR_NAME     = txt_username.Text;
                usersRow.USR_PASSWORD = txt_password.Text;
                usersRow.USR_AGE      = (int)nud_age.Value;

                switch (cbo_type.SelectedText)
                {
                case "Client":
                    usersRow.USR_TYPE = 1;
                    break;

                case "Artiste":
                    usersRow.USR_TYPE = 2;
                    break;

                default:
                    usersRow.USR_TYPE = 1;
                    break;
                }

                usersTableAdapter.InsertQuery(usersRow.USR_NAME, usersRow.USR_PASSWORD, usersRow.USR_TYPE, usersRow.USR_EMAIL, usersRow.USR_AGE);


                lbl_error_msg.Text = "Votre compte a bien été enregistré !";
                Dispose();
            }
            catch (SqlException ex)
            {
                lbl_error_msg.Text = "Une erreur est survenue ! Veuillez introduire des champs valides !";
            }
        }
Beispiel #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Principal"/> class.
        /// </summary>
        public ReferralSystemPrincipal(string username, FormsAuthenticationTicket authTicket)
        {
            this.Username = username;
            UserAuthService userAuthService = DependencyResolver.Current.GetService <UserAuthService>();

            UserViewModel user = userAuthService.GetUser(username);

            this.Identity   = new FormsIdentity(authTicket);
            this.UserID     = user.UserID;
            this.EmployeeID = user.EmployeeID;
            this.RoleType   = user.Type;
        }
        public async Task TryLoadAuthenticationTest(string cookie, bool isValid)
        {
            //ARRANGE
            _ijsRuntimeMock.SetupIjsRuntimeMock <string>("getCookies", cookie);

            var userAuthService = new UserAuthService(_ijsRuntimeMock.Object, _navigationManagerMock.Object, null);

            //ACT
            bool result = await userAuthService.TryLoadAuthentication();

            //ASSERT
            Assert.Equal(isValid, result);
        }
Beispiel #10
0
 public Worker(ILogger <Worker> logger,
               IOptionsMonitor <BaseConfig> optionsAccessor,
               AppState appState,
               UserAuthService userAuthService,
               MediatR.IMediator mediator)
 {
     _mediator        = mediator;
     _userAuthService = userAuthService;
     _logger          = logger;
     _appState        = appState;
     _appState.Config = optionsAccessor.CurrentValue;
     _graphClient     = new GraphServiceClient(userAuthService);
 }
Beispiel #11
0
 public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     if (context.Request.Cookies["userName"] != null)
     {
         string     cookieValue = String.Empty;
         HttpCookie cookie      = new HttpCookie("userName", cookieValue);
         cookie.HttpOnly = true;
         cookie.Expires  = DateTime.Now.AddHours(-1);
         context.Response.Cookies.Remove("userName");
         context.Response.Cookies.Add(cookie);
         UserAuthService.LogOff();
     }
     context.Response.StatusCode = 200;
 }
 public SpotifyController
 (
     IArtistsApi artists,
     IPlayerApi player,
     IUserAccountsService userAccounts,
     UserAuthService authService,
     AuthStateService stateService
 )
 {
     _artists      = artists;
     _userAccounts = userAccounts;
     _authService  = authService;
     _stateService = stateService;
     _player       = player;
 }
Beispiel #13
0
        private async Task <bool> SignUpButtonPressed(UITextField userNameField,
                                                      UITextField passwordField)
        {
            //Creating User Procedure Goes here
            UserAuthService authService = new UserAuthService(new UserData(userNameField.Text,
                                                                           passwordField.Text));
            bool isSuccess = await authService.SignUp();

            if (!isSuccess)
            {
                return(false);
            }

            DismissViewController(true, null);
            return(true);
        }
Beispiel #14
0
        public LightController(
            IOptionsMonitor <BaseConfig> optionsAccessor,
            AppState appState, IServiceScopeFactory _scopeFactory,
            UserAuthService userAuthService,
            ILogger <LightController> logger)
        {
            Config = optionsAccessor.CurrentValue;

            var _scope          = _scopeFactory.CreateScope();
            var ServiceProvider = _scope.ServiceProvider;

            _mediator        = ServiceProvider.GetService <MediatR.IMediator>();
            _userAuthService = userAuthService;
            _appState        = appState;
            _logger          = logger;
        }
Beispiel #15
0
        public JsonResult deleteUser(string uid, string uiid)
        {
            //Console.WriteLine();

            int uidInt  = Convert.ToInt32(uid);
            int uiidInt = Convert.ToInt32(uiid);

            UserUserInfo uui = UserUserInfoService.LoadEntities(u => u.uid == uidInt && u.uiid == uiidInt).FirstOrDefault();

            UserUserInfoService.DeleteEntity(uui);

            UserAuth userAuth = UserAuthService.LoadEntities(u => u.uid == uidInt).FirstOrDefault();

            UserAuthService.DeleteEntity(userAuth);
            //UserService.DeleteEntity(user);

            return(Json("success", JsonRequestBehavior.AllowGet));
        }
Beispiel #16
0
        public JsonResult Login(string username, string password)
        {
            User user = UserService.LoadEntities(u => u.username == username & u.password == password && u.isSys == "1").FirstOrDefault();

            if (user != null)
            {
                UserAuth userAuth = UserAuthService.LoadEntities(u => u.uid == user.uid).FirstOrDefault();
                return(Json(new LoginEntity {
                    msg = "success", code = "200", user = user, userAuth = userAuth
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                return(Json(new LoginEntity {
                    msg = "error", code = "201", user = null
                }, JsonRequestBehavior.AllowGet));
            }
        }
Beispiel #17
0
        private void btn_addProduct_Click(object sender, EventArgs e)
        {
            if (txt_name.TextLength < 1 || txt_price.TextLength < 1)
            {
                MessageBox.Show("Le prix et le nom du produit sont obligatoires !");
                return;
            }
            if (rtxt_description.TextLength < 20)
            {
                MessageBox.Show("Il faut un description de 20 caractères minimum !");
                return;
            }


            // Update the new row to the database
            sLA_PRODUCTSTableAdapter.InsertQuery(UserAuthService.getUserId(), int.Parse(cbo_category.SelectedValue.ToString()), txt_name.Text, txt_price.Text, int.Parse(nud_quantity.Text), rtxt_description.Text, txt_product_pic.Text, 1);
            fv_products.updateProductDataGridView();
            MessageBox.Show("Le produit a bien été ajouté !");
            Hide();
        }
        private async Task <bool> LoginButtonPressed(UITextField userNameField,
                                                     UITextField passwordField,
                                                     object sender)
        {
            //set current user procedure goes here
            UserAuthService authService = new UserAuthService(new UserData(userNameField.Text,
                                                                           passwordField.Text));
            bool isSuccess = await authService.Login();

            if (!isSuccess)
            {
                return(false);
            }

            if (OnLoginSuccess != null)
            {
                OnLoginSuccess(sender, new EventArgs());
            }
            return(true);
        }
Beispiel #19
0
        private void login()
        {
            lbl_error_msg.Text = "";

            if (txt_username.TextLength < 1 || txt_password.TextLength < 1)
            {
                lbl_error_msg.Text = "Veuillez entrer un nom d'utilisateur et un mot de passe !";
                return;
            }

            if (UserAuthService.login(txt_username.Text, txt_password.Text))
            {
                this.main = new Main(this);
                main.Show();
                Hide();
                return;
            }

            lbl_error_msg.Text = "Nom d'utilisateur ou mot de passe incorrect !";
        }
Beispiel #20
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            var userEmail    = context.Request.Params["email"];
            var userPassword = context.Request.Params["password"];

            using (var dbContext = new EntityModel())
            {
                User user = dbContext.Set <User>().Where(u => u.Email == userEmail).FirstOrDefault();
                if (user != null && Crypto.VerifyHashedPassword(user.Password, userPassword))
                {
                    UserAuthService.Authentificate(userEmail);
                    context.Response.StatusCode = 200;
                }
                else
                {
                    context.Response.StatusCode = 400;
                }
            }
        }
Beispiel #21
0
        public async void Authorize_Valid_User()
        {
            var options = new DbContextOptionsBuilder <DashboardDbContext>()
                          .UseInMemoryDatabase(databaseName: "Authorize_Valid_User")
                          .Options;

            var user = new User()
            {
                Email    = "*****@*****.**",
                Password = "******",
                IsActive = true
            };

            using (var context = new DashboardDbContext(options))
            {
                var serviceCheckEmail = new CheckEmailService(context, _mockLoggerCheckEmail.Object);
                var serviceCrud       = new UserCrudService(context, _mockLoggerUserCrud.Object, serviceCheckEmail, _mockSendGridService.Object);

                var userCreate = new User()
                {
                    Email    = user.Email,
                    Password = user.Password,
                    IsActive = user.IsActive
                };

                await serviceCrud.CreateUserAsync(userCreate);

                await context.SaveChangesAsync();
            }

            using (var context = new DashboardDbContext(options))
            {
                var serviceAuth = new UserAuthService(context, _mockLogger.Object);
                var result      = serviceAuth.AuthUser(user);

                Assert.Equal(1, await context.Users.CountAsync());
                Assert.NotNull(result);
                Assert.Equal(user.Email, result.Email);
            }
        }
Beispiel #22
0
 public UserAuthController(UserAuthService userAuthService, SmsService smsService, ILogger <UserAuthController> logger)
 {
     this.logger          = logger;
     this.userAuthService = userAuthService;
     this.smsService      = smsService;
 }
Beispiel #23
0
        private void Main_Load(object sender, EventArgs e)
        {
            flp_articles_list.AutoScroll = true;
            SlaDataSet dataSet = new SlaDataSet();

            SlaDataSetTableAdapters.SLA_PRODUCTSTableAdapter listProducts = new SlaDataSetTableAdapters.SLA_PRODUCTSTableAdapter();
            listProducts.Fill(dataSet.SLA_PRODUCTS);

            foreach (SlaDataSet.SLA_PRODUCTSRow product in listProducts.GetData().Where(p => p.PRD_USR_ID != UserAuthService.getUserId()))
            {
                FlowLayoutPanel flowLayoutPanel = new FlowLayoutPanel();

                Label lbId = new Label();
                lbId.Hide();
                lbId.Text = product.PRD_ID.ToString();

                Label lbNom = new Label();
                lbNom.AutoSize  = false;
                lbNom.Text      = product.PRD_NAME;
                lbNom.TextAlign = ContentAlignment.MiddleCenter;

                Label lbPrix = new Label();
                lbPrix.AutoSize  = false;
                lbPrix.Text      = product.PRD_PRICE + " .-";
                lbPrix.TextAlign = ContentAlignment.MiddleCenter;

                flowLayoutPanel.Size = new Size(78, 122);

                lbNom.Size  = new Size(75, 20);
                lbPrix.Size = new Size(75, 20);


                PictureBox picture = new PictureBox();
                picture.Size = new Size(78, 70);

                flowLayoutPanel.Controls.Add(lbId);
                flowLayoutPanel.Controls.Add(picture);
                flowLayoutPanel.Controls.Add(lbNom);
                flowLayoutPanel.Controls.Add(lbPrix);

                foreach (Control control in flowLayoutPanel.Controls)
                {
                    control.Click += new EventHandler(produit_click);
                }
                flp_articles_list.Controls.Add(flowLayoutPanel);
                picture.Image    = simplart.Properties.Resources.bsi_toomt14;
                picture.SizeMode = PictureBoxSizeMode.StretchImage;
                picture.Refresh();
            }
        }
Beispiel #24
0
 public UserAuthApiController()
 {
     _userService = new UserAuthService();
 }
Beispiel #25
0
 private void seDéconnecterToolStripMenuItem_Click(object sender, EventArgs e)
 {
     UserAuthService.disconnect();
     this.signin.Show();
     this.Dispose();
 }
Beispiel #26
0
        public JsonResult updateAuth(UserAuth userauth)
        {
            bool res = UserAuthService.EditEntity(userauth);

            return(Json(res, JsonRequestBehavior.AllowGet));
        }
Beispiel #27
0
 public void updateProductDataGridView()
 {
     this.sLA_PRODUCTSTableAdapter.FillByUser(this.slaDataSet.SLA_PRODUCTS, UserAuthService.getUserId());
 }