Base solution for your next web application

Activities of "gvb"

I tried to put AbpAuthorize Attribute over my HomeController and still he doesn't do anything.... he still show me a my _layout.cshtml but it shouldn't ?! it should do like in SampleZero and redirect me to the Account/Login MVC Path...

What did i miss to make AbpAuthorize working ??

the documentation doesn't tell anything else than how to put the attribute with permission but doesn't talk about the redirect and what really need to be done to make it work :S and i dont see diference between moduleZeroSample and my project!

[AbpAuthorize]
    public class HomeController : SurveyControllerBase
    {
        public ActionResult Index()
        {
            return View("~/App/Main/views/layout/layout.cshtml");
        }
	}

I'm trying to secure my ApplicationService now,

i checked ModuleZeroSample and tried to do the same but something must be wrong in my code... but i doesn't find the problem :(

When i try to go in a protected route... i have a Popup that say "No user logged in!" with an ok button ? when we click ok it reload the same page.... so there is the infinite loop ?!

What am i doing wrong ?

I did the same for my ParticipantList and this one work i have the same exact code for the client and still the client doesnt work at all.... And my ParticipantList doesnt send his RequestURL to the Login page... so when the user is connecting he doesn't get redirected to the page he was trying to get.

I know it work on sample of Zero Module but i dont know what i'm doing wrong ..!

Thx for the help in advance :)

Application Service

[AbpAuthorize]
    public class GetClientListService : ApplicationService, IGetClientListService

AuthorizationProvider

public class SurveyAuthorizationProvider : AuthorizationProvider
    {
        public override void SetPermissions(IPermissionDefinitionContext context)
        {
              // No Need for special permission at the moment, just to be connected
        }
    }

ApplicationModule

[DependsOn(typeof(SurveyCoreModule))]
    public class SurveyApplicationModule : AbpModule
    {
        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
            Configuration.Authorization.Providers.Add<SurveyAuthorizationProvider>();
            Configuration.Settings.Providers.Add<SurveySettingProvider>();
        }
    }

Startup class in WebProject

public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
                LoginPath = new PathString("/Account/Login")
            });

            app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
        }
    }

AccountController

[HttpPost]
        public async Task<JsonResult> Login(LoginViewModel loginModel, string returnUrl = "")
        {  
            //     ... login validation ....

           if (string.IsNullOrWhiteSpace(returnUrl))
            {
                returnUrl = Request.ApplicationPath;
            }

            return Json(new MvcAjaxResponse { TargetUrl = returnUrl });

        }

Ok i think i understand!

-Create an Object and inherit IAbpSession -Set the property i need in this object then _context.AbpSession = Object that implement IAbpSession -then Insert in the DB.

that was easy -_- but didnt know AbpSession was in the context... sorry ... i should have remembered that i inherit from a different context than normal Entity framework context...

And thx for pointing out the logic for the seed and creatorId. May be i'm wrong to try to associate any entity created to a UserId.

I will try to think about it if i change my logic to put null to entity that are created by SystemSeed.

Calling dbContext.DisableAllFilters() doesn't work either

i wan't to be able to put the creatorid IN the entity creation....

here is my code and it still doesn't create my entity with my adminId..... plz help me on this....

if (!_dto.Context.NewsCategory.Any())
            {
               _dto.Context.DisableAllFilters();

                var framework = _dto.Context.NewsCategory.Add(new NewsCategory
                {
                    Category = "Framework",
                    CreationTime = DateTime.Now,
                    CreatorUserId = _dto.AdminId.Value,
                    IsDeleted = false
                });

                _dto.Context.SaveChanges();

CreatorUserId = NULL in the DB......

and if i save the entity without the ID and save it after the Context.SaveChanges() then the LastModifiedTime is fullfilled and if i set the LastModifierUserId to the admin while assigning the CreatorId ...... the fucking LastModifierUserId = null

Serious....is there a way to achieve it ..?

hey,

I solved this problem with those things :

In BundleConfig.cs Change the code for the Bundle/App/vendor/css by this code, i kept the old code in comment to show what happenned:

//~/Bundles/App/vendor/css
            bundles.Add(
                new StyleBundle("~/Bundles/App/vendor/css")
                    .Include(
                        //"~/Content/themes/base/all.css",
                        "~/Content/bootstrap-cosmo.min.css",
                        "~/Content/toastr.min.css",
                        "~/Scripts/sweetalert/sweet-alert.css"//,
                        //"~/Content/flags/famfamfam-flags.css",
                        //"~/Content/css/font-awesome.min.css"
                    )
                );

            bundles.Add(
                new StyleBundle("~/Content/themes/base/css")
                    .Include(
                        "~/Content/themes/base/all.css"
                    )
                );

            bundles.Add(
                new StyleBundle("~/Content/flags/css")
                .Include(
                    "~/Content/flags/famfamfam-flags.css"
                )
            );

            bundles.Add(
                new StyleBundle("~/fonts/css")
                .Include("~/Content/css/font-awesome.min.css"));

The problem is there is relative reference in those scripts, so we need to keep the same architecture so they can keep their relative path correct. Dont forget to add those new bundle in yours layout.

This will correct so errors but we need to change other things too!

In the WebConfig we need to add a section to tell IIS that we know those MIME type (Font-Awesome) and what they really are...

<system.webServer>
   ....

    <staticContent>
      <remove fileExtension=".svg" />
      <remove fileExtension=".eot" />
      <remove fileExtension=".woff" />
      <mimeMap fileExtension=".svg" mimeType="image/svg+xml" />
      <mimeMap fileExtension=".eot" mimeType="application/vnd.ms-fontobject" />
      <mimeMap fileExtension=".woff" mimeType="application/font-woff" />
      <mimeMap fileExtension=".woff2" mimeType="application/font-woff" />
    </staticContent>

...
  </system.webServer>

And one last thing i've done is adding this line in my layout head:

&lt;base href=&quot;@Url.Content(&quot;~/&quot;)&quot; /&gt;

I think it's all you need to remove those errors!

Just show an other screenshot if something is not working properly i might forgot 1 step :)

Any idea on how to remove the filter SoftDelete from IRepository query ?

Hi,

I'm trying to make a list of my entity and it seem's that i cannot get the entities where the IsDeleted = true

_repoNews.GetAll().Where(x => x.IsDeleted == true).ToList().Count always return 0 but i have at least 1 entity that is Deleted.

Is there a way to get the IsDeleted = true ?

I found that ISoftDelete say ->

/// <summary> /// Used to standardize soft deleting entities. /// Soft-delete entities are not actually deleted, /// marked as IsDeleted = true in the database, /// but can not be retrieved to the application. /// /// </summary>

Is there a way to deactive this for a request?

The thing i wanna make is a list where I see all my entity and see if they are active / inactive (!deleted or deleted) and i want to be able to reactive an entity IsDeleted = true to IsDeleted = false

Ok so i found my solution in the AbpZeroSample

The solution is to create your Entity First then SaveChange and finaly put the CreatorUserId to SaveChange again.

If someone else get this problem!

But someone can explain why i cannot find any user in my _context.Users? i want to be able to get my user created by Seeder in my other Seeding class without keeping them in a SeederDto :S

Here is the modified code :

adminUserForDefaultTenant = _context.Users.Add(
                    new User
                    {
                        TenantId = defaultTenant.Id,
                        UserName = "admin",
                        Name = "System",
                        Surname = "Administrator",
                        EmailAddress = "[email protected]",
                        IsEmailConfirmed = true,
                        Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
                    });
                _context.SaveChanges();

                var category  = _context.NewsCategory.Add(new NewsCategory
                {
                    Category = "Framework",
                    CreationTime = DateTime.Now,
                    IsDeleted = false,
                });
                _context.SaveChanges();

                category.CreatorUserId = adminRoleForDefaultTenant.Id;

                _context.SaveChanges();
Question

hey,

i'm trying to put my initial data in Seed method and the creatorId from IFullAudited nevver get filled with my data.... And I dont understand why my context is getting 0 user from the context when i just saved 3 person in it.... and my db show them....

here is my code in a Seeder class... in the database the CreatorUserId = null .... like WTF? i tried with putting 1.... same result i get null in db... how is it fucking possible that my ID that i put become null ? or why i cant get my users from my context.... i did my SaveChange....

i tried with a _context.Users.First() after the save.... and still it throw no item in the sequence....

and the adminUserForDefaultTenant give me ID 3 when i put a throw new Exception(adminUserForDefaultTenant.Id.ToString()) after the SaveChange... so why it doesn't register as CreatorId 3 when i put it in my NewsCategory?

can anyone help ?

adminUserForDefaultTenant = _context.Users.Add(
                    new User
                    {
                        TenantId = defaultTenant.Id,
                        UserName = "admin",
                        Name = "System",
                        Surname = "Administrator",
                        EmailAddress = "[email protected]",
                        IsEmailConfirmed = true,
                        Password = "AM4OLBpptxBYmM79lGOX9egzZk3vIQU3d/gFCJzaBjAPXzYIK3tQ2N7X4fcrHtElTw==" //123qwe
                    });
                _context.SaveChanges();

                _context.NewsCategory.Add(new NewsCategory
                {
                    Category = "Framework",
                    CreationTime = DateTime.Now,
                    CreatorUserId = adminUserForDefaultTenant.Id,
                    IsDeleted = false,
                });
                _context.SaveChanges();

I didn't find anything usefull in ISettingManager by creating a class then heritate ISettingManager....

The only thing i found usefull is ISmtpEmailSenderConfiguration but i dont know how to use it.... and how to link ISettingManager and ISmtpEmailSenderConfiguration!?

i just found in the doc this part, why configure it there if there is a ISmtpEmailSenderConfiguration?

public override IEnumerable<SettingDefinition> GetSettingDefinitions(SettingDefinitionProviderContext context)
    {
        return new[]
                {
                    new SettingDefinition(
                        "SmtpServerAddress",
                        "127.0.0.1"
                        ),
            ...
    }
Showing 41 to 50 of 53 entries