thanks so much
I also did research through google, but most about how to get token, use token. Did not find out how to let token failure manually. Did a demo by following article, but still did not find out the feature for let token failure manually. <a class="postlink" href="http://bitoftech.net/2014/06/09/angularjs-token-authentication-using-asp-net-web-api-2-owin-asp-net-identity/">http://bitoftech.net/2014/06/09/angular ... -identity/</a>
Hi ismcagdas,
Your understanding is right, and thanks for your good solution.
Thanks!
And I am still thinking if and how can logout on service side directly. Such as to let the token failure.
Hi, What I expected is: 1 call /api/account/Authenticate to get a token 2 Use the token to call an authorized api service 3 logout 4 use the original token to call an authorized api service, expect to get an ‘not login’ error Currently, step 1 and step 2 are works fine. And for logout, I add new action in AccountController in Web Api layer
private IAuthenticationManager AuthenticationManager => Request.GetOwinContext().Authentication;
[HttpPost]
[ActionName("Logout")]
public AjaxResponse Logout()
{
AuthenticationManager.SignOut();
return new AjaxResponse();
}
But when I tested, after call the logout service. Then executed step 4, still success, did not get the ‘not login’ error. Does anyone know that’s the issue is and how to fix?
My opinion is that this should be done in front-end, for service request, if get a error message code with no user login, then the front-end should catch the error and redirect to the login page to get a new token
Thanks so much! Move following code to PostInitialize, now it works fine. Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver();
Thanks so much! And then my understand is: 1 The permissions will created at each module initialization. 2 The created permissions are stored in memory – a dictionary 3 When get all permissions or check permission, the permission data is come from memory – dictionary 4 The AbpPermission data table is for roe-permission relationship Am I right? Please correct me if I am wrong
The permission entity in code has following property: Name, Display name, Description, MultiTenancySides and featureDependency. But in the AbpPermissions data tabble, it just has a name field. Where are the Display name and Description (localization key) stored in?
Hi ismcagdas,,
I add following following code
Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new DefaultContractResolver();
in WebApiModel.Initialize, and the return response still camelCase, not pascalCase.
Then I write a customerContractResolver for pascalCase, still not work
public class PascalCasePropertyNamesContractResolver : DefaultContractResolver
{
public new static readonly PascalCasePropertyNamesContractResolver Instance = new PascalCasePropertyNamesContractResolver();
protected override string ResolvePropertyName(string propertyName)
{
return propertyName.ToPascalCase();
}
}
Configuration.Modules.AbpWebApi().HttpConfiguration.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new PascalCasePropertyNamesContractResolver();
Do you know What am i missing?
BTW, my abp version is 1.2.0.0
Sharing: Using MySql in ABP sample project
1 Download sample project from ABP website 2 Install MySql on windows, create a database named ‘sampledb’ <a class="postlink" href="https://dev.mysql.com/doc/refman/8.0/en/mysql-installer-gui.html">https://dev.mysql.com/doc/refman/8.0/en ... r-gui.html</a> <a class="postlink" href="https://downloads.mysql.com/archives/installer/">https://downloads.mysql.com/archives/installer/</a> 3 Install MySql.Data.Entity in EntityFramwwork and Web Projects Install-Package MySql.Data.Entity -Version 6.8.3 / Install-Package MySql.Data.Entity Please ensure don't install the laest version of MySql.Data.Entity, since the ABP sample project using .net framework 4.5.2, it will cause some exceptions
4 Change web.config in Web Project <entityFramework codeConfigurationType="MySql.Data.Entity.MySqlEFConfiguration, MySql.Data.Entity.EF6"> <defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" /> <providers> <provider invariantName="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlProviderServices, MySql.Data.Entity.EF6" /> <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> </providers> </entityFramework>
<connectionStrings> <add name="Default" providerName="MySql.Data.MySqlClient" connectionString="server=localhost;port=3306;database=sampledb;uid=root;password=*** " /> </connectionStrings>
<a class="postlink" href="http://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html">http://dev.mysql.com/doc/connector-net/ ... ork60.html</a>
5 Run Update-Database –Verbos 6 Then you can run the sample ABP project successfully.