so any idea on how to protect route ? or WebAPI route!?
And how do i control, because if i put the AbpMvcAuthorize, it will ask authentication for all my route ? no ?
mysite.com/#/client/list <-- Require authentication mysite.com/#/news/create <-- Require authentication mysite.com/#/news <-- Doesn't require authentication mysite.com/#/project <-- Doesn't require authentication
Thx for your help, it help a lot ! :)
hmmm it seem's strange to me! because your ModuleZeroSample work as i want ... if i try to access a page that have an AbpAuthorize i got redirected to the Login Page!
Why i dont get this with my AbpAuthorize....
OR how do i protect my page from being accessed by user that he doesn't have access like
mysite.com/#/client/list <--- Required User to be Connected!
in my system you only need to be connected to check the client list, so if u enter the URL manually or save the page in ur favorite, i just want you to be redirected to login page then to the page back when you are connected!
I dont have any Button with an action that appear and shouldn't
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");
}
}
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:
<base href="@Url.Content("~/")" />
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 ?
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();
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"
),
...
}