Exemplo n.º 1
0
        public static UserInfo GetUserByName(string userName, bool isTest = false)
        {
            ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest);

            UserInfo user = sprocCalls.UserInfoGetByUser(userName);

            if (user != null)
            {
                user.GroupUsers = GetGroupsByUserName(userName, sprocCalls);
            }

            return(user);
        }
Exemplo n.º 2
0
        public static void RecoverPassword(RecoverModel model, string location, out string errorMessage, bool isTest = false)
        {
            try
            {
                ISprocCalls sprocCalls = AppTools.InitSprocCalls(isTest);
                errorMessage = string.Empty;

                UserInfo user = sprocCalls.UserInfoGetByUser(model.UserName);
                if (model.Email == user.Email)
                {
                    string code = RandomCode(7);
                    while (sprocCalls.UserInfoGetByCode(code) != null)
                    {
                        code = RandomCode(7);
                    }

                    user.GroupUsers  = GetGroupsByUserName(model.UserName, sprocCalls);
                    user.RecoverCode = RandomCode(7);

                    if (sprocCalls.UserInfoUpdate(user) == false)
                    {
                        errorMessage = "Error recovering password.";
                    }
                    else if (SendRecoverEmail(user, location, isTest) == false)
                    {
                        errorMessage = "Error sending email.";
                    }
                }
                else
                {
                    errorMessage = (user != null) ? "Email and username is not valid." : "Error loading user";
                }
            }
            catch (Exception ex)
            {
                DBCommands.RecordError(ex);
                errorMessage = ex.Message;
            }
        }