Exemplo n.º 1
0
        public bool UpdatePassword(string oldPassword)
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_CHANGE_PASSWORD);

            proc.AddInput("@userId", UserId, System.Data.SqlDbType.Int);
            proc.AddInput("@oldPassword", oldPassword.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@newPassword", Password.Trim(), System.Data.SqlDbType.VarChar);

            System.Data.SqlClient.SqlParameter resultParam = proc.AddOutput("@result", System.Data.SqlDbType.Bit);

            result = proc.Execute();

            if (result)
            {
                result = Convert.ToBoolean(resultParam.Value);

                if (!result)
                {
                    throw new Exception("Old password incorrect.");
                }
            }

            return(result);
        }
Exemplo n.º 2
0
        public bool ValidateLogin()
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_VALIDATE_LOGIN);

            proc.AddInput("@userName", UserName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@password", Password.Trim(), System.Data.SqlDbType.VarChar);

            System.Data.SqlClient.SqlParameter idParam = proc.AddOutput("@userId", System.Data.SqlDbType.Int);

            result = proc.Execute();

            if (result)
            {
                if (idParam.Value != DBNull.Value)
                {
                    UserId = Convert.ToInt32(idParam.Value);
                }
                else
                {
                    UserId = 0;
                }
            }
            else
            {
                UserId = 0;
            }

            return(result);
        }
Exemplo n.º 3
0
        internal static void Login(string userName, string password, out int userNo, out bool blocked, out bool canLogin)
        {
            using (var spo = new StoredProcedure("usp_User_loginGame", DB.GetDatabaseClient(DatabaseType.Account).mConnection))
            {
                spo.AddParameter("userID", userName, 20);
                spo.AddParameter("userPW", password, 32);

                spo.AddOutput <int>("userNo");
                spo.AddOutput <byte>("authID");
                spo.AddOutput <int>("block");
                spo.AddOutput <int>("isLoginable");

                spo.Run();

                userNo   = spo.GetOutput <int>("userNo");
                blocked  = spo.GetOutput <int>("block") == 1;
                canLogin = spo.GetOutput <int>("isLoginable") == 1;
            }
        }
Exemplo n.º 4
0
        // User must use a stored procedure so that the SQL server can handle password encryption.
        public override bool Add()
        {
            bool result;

            StoredProcedure proc = new StoredProcedure(Constants.CONNECTION_STRING, Constants.STORED_PROC_ADD_USER);

            proc.AddInput("@userName", UserName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@email", Email.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@password", Password.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@displayName", DisplayName.Trim(), System.Data.SqlDbType.VarChar);
            proc.AddInput("@description", Description.Trim(), System.Data.SqlDbType.VarChar);

            System.Data.SqlClient.SqlParameter idParam = proc.AddOutput("@userId", System.Data.SqlDbType.Int);

            result = proc.Execute();

            if (result)
            {
                UserId = Convert.ToInt32(idParam.Value);
            }

            return(result);
        }
Exemplo n.º 5
0
        public static async Task <bool> Create(CreateProposalModel model)
        {
            using (var p_Proposal_Create = new StoredProcedure("p_Proposal_Create"))
            {
                p_Proposal_Create.AddParameter("sStudyFields", string.Join(';', model.Study));
                p_Proposal_Create.AddParameter("sDescription", model.Description);
                p_Proposal_Create.AddParameter("sToolsUsed", string.Join(';', model.Environment));
                p_Proposal_Create.AddParameter("sToolsInformation", model.TechnicalDescription);
                p_Proposal_Create.AddParameter("sNecessities", model.ExtraRequirements);
                p_Proposal_Create.AddParameter("sTheme", model.Theme);
                p_Proposal_Create.AddParameter("sActivities", string.Join(';', model.Activities));
                p_Proposal_Create.AddParameter("nRequiredStudents", model.AmountOfStudents);
                p_Proposal_Create.AddParameter("sPreferedStudents", string.Join(';', model.Names));
                p_Proposal_Create.AddParameter("sOptionalComment", model.Remarks);
                p_Proposal_Create.AddParameter("sPeriods", string.Join(';', model.Period));
                p_Proposal_Create.AddOutput <int>("nID");

                p_Proposal_Create.Run();

                return(true);
                // F**k checking temporarily.
                //return (await p_Proposal_Create.Run()).GetOutput<int>("nID") != 0;
            }
        }