Esempio n. 1
0
        public async Task Invoke(HttpContext context)
        {
            var user = UserReader.GetUser(context);

            if (user?.Entity != null)
            {
                var router = context.GetRouteData();

                router.Values.TryGetValue("controller", out object value);
                var controller = (string)value;

                // Check if the user is fully authenticated
                if (user.Entity.AuthenticatorSecret != null && !user.FullyAuthenticated)
                {
                    // When the user not fully authenticated, restrict all other controllers than authentication
                    if (controller != "Authenticator")
                    {
                        context.Response.Redirect("/Authenticator/Validate");
                        return;
                    }
                }
            }

            await next(context);
        }
Esempio n. 2
0
        public async Task <ActionResult> Create(string currency, string userName, string returnUrl)
        {
            var user = await UserManager.FindValidByIdAsync(User.Identity.GetUserId());

            var currencyData = await CurrencyReader.GetCurrency(currency);

            if (currencyData == null || user == null)
            {
                ViewBag.Message = String.Format(Resources.UserWallet.transferCurrencyNotFoundError, currency);
                return(View("Error"));
            }

            if (currencyData.Status == CurrencyStatus.Maintenance || currencyData.Status == CurrencyStatus.Offline)
            {
                ViewBag.HideSupportLink = true;
                ViewBag.SubTitle        = String.Format("{0}: {1}", Resources.UserWallet.transferCreateStatusLabel, currencyData.Status);
                ViewBag.Message         = $"{Resources.UserWallet.transferCreateErrorMessage} <br /><br /> {Resources.UserWallet.transferCreateStatusLabel}: {currencyData.Status}<br />{Resources.UserWallet.transferCreateReasonLabel}: {(string.IsNullOrEmpty(currencyData.StatusMessage) ? Resources.UserWallet.transferCreateUnknownError : currencyData.StatusMessage)}";
                return(View("Error"));
            }

            var checkUser = await UserReader.GetUserByName(userName);

            return(View(await CreateTransferModel(user, new TransferCurrencyModel
            {
                Name = currencyData.Name,
                Symbol = currencyData.Symbol,
                ReturnUrl = GetLocalReturnUrl(returnUrl),
                UserName = checkUser?.UserName
            })));
        }
Esempio n. 3
0
        public async Task <CreateTransferResponseModel> SubmitUserTransfer(ApiSubmitUserTransferRequest request)
        {
            var currency = request.CurrencyId.HasValue
                                ? await CurrencyReader.GetCurrency(request.CurrencyId.Value).ConfigureAwait(false)
                                : await CurrencyReader.GetCurrency(request.Currency).ConfigureAwait(false);

            if (currency == null)
            {
                return new CreateTransferResponseModel {
                           Error = "Currency not found."
                }
            }
            ;

            var receiver = await UserReader.GetUserByName(request.UserName).ConfigureAwait(false);

            if (receiver == null)
            {
                return new CreateTransferResponseModel {
                           Error = "Receiver not found."
                }
            }
            ;

            var response = await TradeService.CreateTransfer(request.UserId.ToString(), new CreateTransferModel
            {
                CurrencyId   = currency.CurrencyId,
                Amount       = request.Amount,
                TransferType = TransferType.User,
                Receiver     = receiver.UserId
            }, true).ConfigureAwait(false);

            return(response);
        }
 public ActionResult LoginExec(AccountLoginViewModel accountLogin)
 {
     if (ModelState.IsValid)
     {
         string          filePath      = Server.MapPath(@"/App_Data/Utenti.txt");
         var             reader        = new UserReader();
         IList <Account> listaAccount  = reader.Read(filePath);
         Account         verificaEmail = listaAccount.FirstOrDefault(e => e.Email == accountLogin.Email);
         if (verificaEmail == null)
         {
             ModelState.AddModelError("Email", "Email non presente");
             return(View("Login"));
         }
         Account verificaAccount = listaAccount.FirstOrDefault(e => e.Email == accountLogin.Email && e.Password == accountLogin.Password);
         if (verificaAccount == null)
         {
             ModelState.AddModelError("", "Credenziali Errate");
             return(View("Login"));
         }
         Session["user"]   = verificaAccount;
         Session["logged"] = true;
         return(RedirectToAction("Index", "Home"));
     }
     return(View("Login"));
 }
Esempio n. 5
0
        public IEnumerable <User> Get(Config c)
        {
            c.OrgsWithPATs = AzDevOpsReader.LoadAllOrgsFromPAT(c).Result.ToArray();

            List <User> result = new List <User>();

            foreach (var orgWithPAT in c.OrgsWithPATs)
            {
                foreach (var org in orgWithPAT.Orgs)
                {
                    var ur = new UserReader(org, orgWithPAT.Pat);
                    result.AddRange(ur.ReadUsers().Result);

                    //foreach(var usr in resultsUsers.Values)

                    //tasksLicenseSummaries.Add(ur.ReadLicenseSummary());
                    //tasksEntities.Add(ur.ReadEntity());
                    //internalStakeholdersCount[org] = 0;
                    //internalBasicsCount[org] = 0;
                    //internalTestsCount[org] = 0;
                    //internalVSCount[org] = 0;
                }
            }
            return(result);
        }
        //Show searched records
        public void OnPostSearch()
        {
            String          Search_User     = Request.Form["Search_User"];
            String          Exception       = "";
            String          Current_User    = HttpContext.Session.GetString("User_Name");
            int             OFFSET          = 50;
            Boolean         CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception);
            MySqlCommand    MySQLQuery      = new MySqlCommand();
            MySqlDataReader UserReader;

            UserList = new List <String> {
            };
            if (Search_User != null || Search_User.CompareTo("") != 0)
            {
                HttpContext.Session.SetString("Search_User", Search_User);
                HttpContext.Session.SetString("OFFSET", OFFSET.ToString());
                SessionSearchUser = Search_User;
                MySQLQuery        = new MySqlCommand();
                MySQLQuery.Parameters.Clear();
                MySQLQuery.CommandText = "SELECT `User_Name` FROM `User` WHERE `User_Name`!='@Current_User' AND `User_Name` LIKE '%@Search_User%' LIMIT 50";
                MySQLQuery.Parameters.Add("@Search_User", MySqlDbType.Text).Value  = Search_User;
                MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User;
                MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection;
                MySQLQuery.Prepare();
                UserReader = MySQLQuery.ExecuteReader();
                while (UserReader.Read())
                {
                    UserList.Add(UserReader.GetValue(0).ToString());
                }
                MyOwnMySQLConnectionClass.MyMySQLConnection.Close();
            }
        }
Esempio n. 7
0
        /// <summary>
        /// This method fetches a  'List<User>' object.
        /// This method uses the 'Users_FetchAll' procedure.
        /// </summary>
        /// <returns>A 'List<User>'</returns>
        /// </summary>
        public List <User> FetchAllUsers(FetchAllUsersStoredProcedure fetchAllUsersProc, DataConnector databaseConnector)
        {
            // Initial Value
            List <User> userCollection = null;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // First Get Dataset
                DataSet allUsersDataSet = this.DataHelper.LoadDataSet(fetchAllUsersProc, databaseConnector);

                // Verify DataSet Exists
                if (allUsersDataSet != null)
                {
                    // Get DataTable From DataSet
                    DataTable table = this.DataHelper.ReturnFirstTable(allUsersDataSet);

                    // if table exists
                    if (table != null)
                    {
                        // Load Collection
                        userCollection = UserReader.LoadCollection(table);
                    }
                }
            }

            // return value
            return(userCollection);
        }
Esempio n. 8
0
        /// <summary>
        /// This method finds a  'User' object.
        /// This method uses the 'User_Find' procedure.
        /// </summary>
        /// <returns>A 'User' object.</returns>
        /// </summary>
        public User FindUser(FindUserStoredProcedure findUserProc, DataConnector databaseConnector)
        {
            // Initial Value
            User user = null;

            // Verify database connection is connected
            if ((databaseConnector != null) && (databaseConnector.Connected))
            {
                // First Get Dataset
                DataSet userDataSet = this.DataHelper.LoadDataSet(findUserProc, databaseConnector);

                // Verify DataSet Exists
                if (userDataSet != null)
                {
                    // Get DataTable From DataSet
                    DataRow row = this.DataHelper.ReturnFirstRow(userDataSet);

                    // if row exists
                    if (row != null)
                    {
                        // Load User
                        user = UserReader.Load(row);
                    }
                }
            }

            // return value
            return(user);
        }
Esempio n. 9
0
        public async Task <ActionResult> Index(int gameId)
        {
            var userTeam = default(TeamModel);
            var teams    = new List <TeamModel>();
            var userId   = User.Identity.GetUserId <int>();
            var game     = await GameReader.GetGame(gameId);

            if (game.Status == GameStatus.Finished)
            {
                return(RedirectToAction("Game", "Gallery", new { gameId = gameId }));
            }

            var user = await UserReader.GetUser(userId);

            if (game.Type == GameType.TeamBattle)
            {
                teams = await GameReader.GetTeams(game.Id);

                userTeam = await GameReader.GetUserTeam(userId, game.Id);
            }

            return(View(new PixelViewlModel
            {
                Game = game,
                Points = user?.Points ?? 0,
                Teams = teams,
                Team = userTeam
            }));
        }
Esempio n. 10
0
    bool FindAdmin(string NameToFind)
    {
        bool            UserFind = false;
        MySqlCommand    UserCommand;
        MySqlDataReader UserReader;

        Connection.Open();
        if (Connection != null)
        {
            UserCommand             = Connection.CreateCommand();
            UserCommand.CommandText = "Select login from admin where login ='******'";
            UserReader = UserCommand.ExecuteReader();
            if (UserReader.Read())
            {
                if (UserReader["login"].ToString() == NameToFind)
                {
                    UserFind = true;
                }
            }
            UserReader.Close();
            Connection.Close();
        }
        else
        {
            //connexion non réussie
            Response.Redirect("default.aspx");
        }
        return(UserFind);
    }
Esempio n. 11
0
        public async Task <ActionResult> ApproveChangeEmail(int approvalId)
        {
            var model = await AdminApprovalReader.GetApproval(approvalId);

            if (model == null)
            {
                return
                    (ViewMessageModal(new ViewMessageModel(ViewMessageType.Warning, "Approval Not Found!",
                                                           $"Could not find EmailChange approval #{approvalId}")));
            }

            var user = await UserReader.GetUserByName(model.DataUser);

            return(View("ChangeEmailApproveModal", new AdminChangeEmailApproveModel
            {
                Status = model.Status,
                Requestor = model.RequestUser,
                Requested = model.Created,
                Approved = model.Approved,
                Approver = model.ApprovalUser,
                Message = model.Message,
                UserName = model.DataUser,
                NewEmailAddress = model.Data,
                OldEmailAddress = user.Email,
                ApprovalId = approvalId
            }));
        }
Esempio n. 12
0
        public async Task <ActionResult> Create(TransferCurrencyModel model)
        {
            var currencyData = await CurrencyReader.GetCurrency(model.Symbol);

            var user = await UserManager.FindValidByIdAsync(User.Identity.GetUserId());

            if (currencyData == null || user == null)
            {
                ViewBag.Message = String.Format(Resources.UserWallet.transferCurrencyNotFoundError, model.Symbol);
                return(View("Error"));
            }

            // Verify User
            var receivingUser = await UserReader.GetUserByName(model.UserName);

            if (receivingUser == null)
            {
                ModelState.AddModelError("UserName", String.Format(Resources.UserWallet.transferUserNotFoundError, model.UserName));
                return(View(await CreateTransferModel(user, model)));
            }
            if (receivingUser.UserId.Equals(User.Identity.GetUserId(), StringComparison.OrdinalIgnoreCase))
            {
                ModelState.AddModelError("UserName", Resources.UserWallet.transferUserIgnoredError);
                return(View(await CreateTransferModel(user, model)));
            }

            // Verify Amount
            if (model.Amount < 0.00000001m)
            {
                ModelState.AddModelError("Amount", String.Format(Resources.UserWallet.transferMinAmountError, "0.00000001", currencyData.Symbol));
                return(View(await CreateTransferModel(user, model)));
            }

            // Verify Two Factor
            if (!await UserManager.VerifyUserTwoFactorCodeAsync(TwoFactorComponent.Transfer, user.Id, model.Code1, model.Code2))
            {
                ModelState.AddModelError("TwoFactorError", Resources.UserWallet.transferTwoFactorFailedError);
                return(View(await CreateTransferModel(user, model)));
            }

            // Create transfer
            var result = await TradeService.CreateTransfer(User.Identity.GetUserId(), new CreateTransferModel
            {
                Receiver     = receivingUser.UserId,
                Amount       = model.Amount,
                CurrencyId   = model.CurrencyId,
                TransferType = TransferType.User
            });

            if (result.IsError)
            {
                ModelState.AddModelError("Error", result.Error);
                return(View(await CreateTransferModel(user, model)));
            }

            return(RedirectToAction("Summary", new { transferId = result.TransferId, returnUrl = GetLocalReturnUrl(model.ReturnUrl) }));
        }
        //Show previous records
        public void OnPostPrevious()
        {
            String          User            = HttpContext.Session.GetString("Search_User");
            String          OFFSETString    = HttpContext.Session.GetString("OFFSET");
            String          Exception       = "";
            String          Current_User    = HttpContext.Session.GetString("User_Name");
            Boolean         CheckConnection = MyOwnMySQLConnectionClass.LoadConnection(ref Exception);
            MySqlCommand    MySQLQuery      = new MySqlCommand();
            MySqlDataReader UserReader;

            UserList = new List <String> {
            };
            int OFFSET = 0;

            SessionSearchUser = User;
            if (User != null && OFFSETString != null)
            {
                OFFSET = int.Parse(OFFSETString);
                if (OFFSET != 0)
                {
                    OFFSET -= 50;
                }
                MySQLQuery.CommandText = "SELECT `User_Name` FROM `User` WHERE `User_Name`!='@Current_User' AND `User_Name` LIKE '%@Search_User%' LIMIT 50 OFFSET " + OFFSET.ToString();
                MySQLQuery.Parameters.Add("@Search_User", MySqlDbType.Text).Value  = User;
                MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User;
                MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection;
                MySQLQuery.Prepare();
                UserReader = MySQLQuery.ExecuteReader();
                while (UserReader.Read())
                {
                    UserList.Add(UserReader.GetValue(0).ToString());
                }
                MyOwnMySQLConnectionClass.MyMySQLConnection.Close();
                HttpContext.Session.SetString("OFFSET", OFFSET.ToString());
            }
            else if (User == null && OFFSETString != null)
            {
                OFFSET = int.Parse(OFFSETString);
                if (OFFSET != 0)
                {
                    OFFSET -= 50;
                }
                MySQLQuery.CommandText = "SELECT `User_Name` FROM `User` WHERE `User_Name`!='@Current_User' LIMIT 50 OFFSET " + OFFSET.ToString();
                MySQLQuery.Parameters.Add("@Current_User", MySqlDbType.Text).Value = Current_User;
                MySQLQuery.Connection = MyOwnMySQLConnectionClass.MyMySQLConnection;
                MySQLQuery.Prepare();
                UserReader = MySQLQuery.ExecuteReader();
                while (UserReader.Read())
                {
                    UserList.Add(UserReader.GetValue(0).ToString());
                }
                MyOwnMySQLConnectionClass.MyMySQLConnection.Close();
                HttpContext.Session.SetString("OFFSET", OFFSET.ToString());
            }
        }
Esempio n. 14
0
        public async Task <ActionResult> CheckUser(string userName)
        {
            var checkUser = await UserReader.GetUserByName(userName);

            if (checkUser != null)
            {
                return(JsonSuccess());
            }

            return(JsonError());
        }
Esempio n. 15
0
        public async Task <ActionResult> UpdateUser(string userId)
        {
            var userupdateModel = await UserReader.GetUserUpdate(userId);

            if (userupdateModel == null)
            {
                return(ViewMessageModal(new ViewMessageModel(ViewMessageType.Warning, "User Not Found!", "Unable to find user information.")));
            }

            return(View("UpdateUserModal", userupdateModel));
        }
Esempio n. 16
0
        public void TestExceptions()
        {
            //IRead<Entity> reader = new EntityReader();
            IRead <Entity> reader = new UserReader();

            try
            {
                reader.ReadOne(0);
            }
            catch (EntityNotFoundException exception)
            {
                Assert.IsTrue(exception is EntityNotFoundException);
            }
        }
Esempio n. 17
0
        public async Task <ActionResult> Index()
        {
            var userId = User.Identity.GetUserId <int>();
            var user   = await UserReader.GetUser(userId);

            var userAwards = await AwardReader.GetUserAwardList(userId);

            return(View(new PointsModel
            {
                Points = user.Points,
                LatestPrizes = new System.Collections.Generic.List <PrizeUserHistoryItemModel>(),
                AwardList = userAwards
            }));
        }
Esempio n. 18
0
        public async Task <ActionResult> UpdateUserModal(int userId)
        {
            var user = await UserReader.GetUser(userId);

            return(View(new UpdateUserModal
            {
                Id = user.Id,
                UserName = user.UserName,
                Email = user.Email,
                Points = user.Points,
                IsEmailConfirmed = user.IsEmailConfirmed,
                IsLocked = user.IsLocked
            }));
        }
Esempio n. 19
0
        public static void CreateUser(string name)
        {
            //Check to see if we have an existing name
            Components.Models.User user = UserReader.GetUserByName(name);

            if (user == null)
            {
                user = new Components.Models.User(name);
                UserWriter.CreateUser(user);
            }
            else
            {
                throw new MembershipCreateUserException(MembershipCreateStatus.DuplicateUserName);
            }
        }
Esempio n. 20
0
        public async Task <ActionResult> Index(string name)
        {
            var user = await UserReader.GetUserProfile(name);

            var awards = await AwardReader.GetUserAwardList(user.Id);

            return(View(new UserProfileViewModel
            {
                Id = user.Id,
                UserName = user.UserName,
                Clicks = user.Clicks,
                Pixels = user.Pixels,
                Awards = user.Awards,
                AwardList = awards
            }));
        }
Esempio n. 21
0
        public IHttpActionResult Post(string userId, string otherUserId)
        {
            var userRes = UserReader.Lookup(userId).SelectError(
                error => error.Accept(UserLookupError.Switch(
                                          onInvalidId: "Invalid user ID.",
                                          onNotFound:  "User not found.")));
            var otherUserRes = UserReader.Lookup(otherUserId).SelectError(
                error => error.Accept(UserLookupError.Switch(
                                          onInvalidId: "Invalid ID for other user.",
                                          onNotFound:  "Other user not found.")));

            var connect =
                from user in userRes
                from otherUser in otherUserRes
                select Connect(user, otherUser);

            return(connect.SelectBoth(Ok, BadRequest).Bifold());
        }
        public ActionResult Index()
        {
            if (Session["loggedAdmin"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            string                   filePath              = Server.MapPath(@"/App_Data/Utenti.txt");
            var                      reader                = new UserReader();
            IList <Account>          listaAccount          = reader.Read(filePath);
            IList <AccountViewModel> listaAccountViewModel = listaAccount.Select(account => new AccountViewModel()
            {
                Id          = account.Id,
                Nome        = account.Nome,
                Cognome     = account.Cognome,
                Email       = account.Email,
                TipoAccount = (Account.tipo.Normal == account.Tipo)?"Normale":"Premium"
            }).ToList();

            return(View(listaAccountViewModel));
        }
        public ActionResult Edit(int Id)
        {
            if (Session["loggedAdmin"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            string           filePath     = Server.MapPath(@"/App_Data/Utenti.txt");
            var              reader       = new UserReader();
            IList <Account>  listaAccount = reader.Read(filePath);
            AccountViewModel account      = listaAccount.Where(e => e.Id == Id).Select(acc => new AccountViewModel()
            {
                Id          = acc.Id,
                Nome        = acc.Nome,
                Cognome     = acc.Cognome,
                Email       = acc.Email,
                TipoAccount = (acc.Tipo == Account.tipo.Normal) ? "Normal" : "Premium"
            }).First();

            return(View(account));
        }
Esempio n. 24
0
        private void LoginBtn_Click(object sender, EventArgs e)
        {
            SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=PHONEANDMORE;Integrated Security=True");

            conn.Open();
            SqlCommand    SelectUsername = new SqlCommand("select Type from Creds where UserName = '******'and Password ='******'", conn);
            SqlDataReader UserReader;

            UserReader = SelectUsername.ExecuteReader();
            if (UserReader.Read() == true)
            {
                if (UserReader[0].ToString() == "admin" || UserReader[0].ToString() == "user")
                {
                    MainMenu ah = new MainMenu();
                    ah.get(UserTextBox.Text);
                    ah.ShowDialog();
                    this.Close();
                }
            }

            else
            {
                if (UserTextBox.Text == "Elbeld" && PassTextBox.Text == "stG65gr5")
                {
                    MainMenu ah = new MainMenu();
                    ah.get(UserTextBox.Text);
                    ah.ShowDialog();
                    this.Close();
                }
                else
                {
                    MessageBox.Show(" incorrect Username or Password, Please check your entries correctly ", "\t\t Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                    UserTextBox.Clear();
                    PassTextBox.Clear();
                    UserTextBox.Focus();
                    conn.Close();
                    UserReader.Close();
                }
            }
            conn.Close();
        }
        public ActionResult Edit(int Id, string tipo)
        {
            if (Session["loggedAdmin"] == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            string          filePath     = Server.MapPath(@"/App_Data/Utenti.txt");
            var             reader       = new UserReader();
            var             writer       = new UserWriter();
            IList <Account> listaAccount = reader.Read(filePath);
            var             daAggiornare = listaAccount.First(e => e.Id == Id);

            daAggiornare.Tipo = (tipo == "Normal") ? Account.tipo.Normal : Account.tipo.Premium;
            writer.Reset(filePath);
            foreach (var account in listaAccount)
            {
                int    Tipo  = (account.Tipo == Account.tipo.Normal) ? 1 : 2;
                string linea = $"{account.Id},{account.Nome},{account.Cognome},{account.Email},{account.Password},{Tipo}";
                writer.Append(filePath, linea);
            }
            return(RedirectToAction("Index", "Account"));
        }
Esempio n. 26
0
        private string GetAlias()
        {
            var reader = new UserReader();

            return(reader.GetAliasByUser(1));
        }
Esempio n. 27
0
        public async Task <ActionResult> GetUsers(DataTablesModel model)
        {
            var result = DataTable(await UserReader.GetUsers(model));

            return(result);
        }
Esempio n. 28
0
 public async Task <ActionResult> GetUsers(DataTablesParam model)
 {
     return(DataTable(await UserReader.GetUsers(model)));
 }
Esempio n. 29
0
        public async Task <ActionResult> Index()
        {
            var user = await UserReader.GetUser(User.Identity.GetUserId <int>());

            return(View(new UserSettingsModel()));
        }
Esempio n. 30
0
        private static IEnumerable <UserBO> GetUsers()
        {
            var userReader = new UserReader();

            return(userReader.GetAllUsers());
        }