asp.net-identity

How to change default error messages of MVC Core ValidationSummary?

廉价感情. 提交于 2019-12-05 22:42:43
问题 Using MVC Core with ASP.NET Identity I would like to change the defaults error messages of ValidationSummary that arrived from Register action. Any advice will be much appreciated. 回答1: You should override methods of IdentityErrorDescriber to change identity error messages. public class YourIdentityErrorDescriber : IdentityErrorDescriber { public override IdentityError PasswordRequiresUpper() { return new IdentityError { Code = nameof(PasswordRequiresUpper), Description = "<your error message

Hosting ASOS with TestServer

一个人想着一个人 提交于 2019-12-05 21:40:49
I have an OpenIdDict authentication server which is based on AspNet.Security.OpenIdConnect.Server . The setup works as expected. Now to do some in process integration;system tests which span the whole backend architecture I use the TestServer class. Why I test like this is another question Most test code coverage with least amount of work It has been decided to not do unit tests... (too much work they say) Real integration tests which span much less code where also seen as to much work when I want to achieve a good coverage The test are based on an framework that is build using a domain

How to show MVC logged in username with AngularJs

試著忘記壹切 提交于 2019-12-05 20:15:23
I am using MVC 5 / WebApi 2 and AngularJs. I want to display the Logged in username in my view. I know how to display that information using razor but how can I do it with Angular? So basically I need to do this with Angular. <span >Logged In As: @Html.ActionLink(User.Identity.GetUserName(), "Manage", "Account", routeValues: null, htmlAttributes: new { title = "Manage", @style = "color:white;float:right" })</span> apiUserController public class apiUserController : ApiController { // GET api/<controller> public List<ApplicationUser> Get() { using (var context = new ApplicationDbContext()) {

Asp.Net Identity - case insensitive email and usernames

落花浮王杯 提交于 2019-12-05 19:27:30
Is there a way to get Asp.Net Identity to be case insensitive with email addresses and usernames? At the moment if I call "FindByEmailAsync(email)" it will only work if the email address is being stored exactly as it's is typed (case sensitive) You can change how the user is registered so that the username is set to lowercase and when logging in as well. For registering the user, in the AccountController [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> Register(RegisterViewModel model) { if (ModelState.IsValid) { var user = new ApplicationUser() { UserName

Create a default user account using ASP.NET Idenity

北城余情 提交于 2019-12-05 18:52:35
I am developing a simple application using ASP.NET MVC 5 and the Identity API. I would like to ask how I am able to create a Super Administrator account inside a Super Administrators role upon creation of the tables and startup of the application. I am using the default ASP.NET MVC 5 with Individual Accounts template of Visual Studio 2013 and I am not sure how to do what I aim. Never mind, I found this useful link that shows exactly what I want: https://github.com/rustd/AspnetIdentitySample/blob/master/AspnetIdentitySample/App_Start/IdentityConfig.cs I do it inside of seed() method of

Authorisation Policy in Identity 3 MVC 6

落花浮王杯 提交于 2019-12-05 18:40:26
I have done a lot of research but am still not sure if I am doing this correctly. The best resource I found was here http://leastprivilege.com/2015/10/12/the-state-of-security-in-asp-net-5-and-mvc-6-authorization/ Given an ApplicationUser class extended to include a list of Authorized account numbers I want to restrict the user to only view statements (and other actions based) on their authorized accounts). I would think this is a very common design however most of the articles on the net refer to previous versions of identity. (PS I am injecting UserManager in the Controller constructor) Here

Asp.net core - no such table: AspNetUsers

一曲冷凌霜 提交于 2019-12-05 18:29:41
So im trying to implment user login for my a asp.net core application. Im following the microsoft tutorial here . I have two contexts, one called SchoolContext for saving all the school related models, and another context called ApplicationDbContext for the Account models. This is all being saved to a sqlite database. Everything works fine, up until I try to register a user to my context. When I try to register a user i get, cant find AspNetUsers table error. If I look in the database I don’t see the AspNetUser table. I tried adding migrations , but i still get that same error. Why is the

ASP.NET core Web API Authorize Attribute return 404 Error & force redirect

℡╲_俬逩灬. 提交于 2019-12-05 16:43:26
I have asp.net core 2.0 solution which contains following projects: Data: a class library for EF code OAuth: as web application project for IdentityServer4 code Api: for my API created as empty web project Now the OAuth project is configured with aspnetidentity and its working fine, I able to get the token after authentication, and this is the startup code for it: public void ConfigureServices(IServiceCollection services) { // connect with normal database services.AddDbContext<MCareContext>(options => options.UseSqlServer(Configuration .GetConnectionString("MCareConnection"))); services

ASP.NET Core Identity 3 Cookie timeout

不想你离开。 提交于 2019-12-05 12:33:47
I have a weird issue happening with RC2. I have setup Identity 3 ExpireTimeSpan to 12 hours using the following configuration option options.Cookies.ApplicationCookie.ExpireTimeSpan = new TimeSpan(12,0,0); After logging in to the website and leaving it untouched for ~35-40mins, I get a 401 error (for my ajax post calls) and refreshing the website, I get back to the login page. Why do I have to reauthenticate when I have setup the ExpireTimeSpan to 12hours? Is there another setting or configuration that I need? Also, How can I get the time left before the expiry occurs? I would like to access

How to create a security stamp value for asp.net identity (IUserSecurityStampStore)

自古美人都是妖i 提交于 2019-12-05 12:11:36
问题 In my MVC-5 application, I have to create security stamp values manually . The current implementation of the identity team seems to use a guid. Guid.NewGuid().ToString("D") Is it safe to create a new Guid myself to use as a new security stamp value or will this lead to problems in future implementations of asp.net identity? Is there a method to let the identity framework create such a stamp-value for me so that my implementation is safe for future changes? 回答1: Out of the documentation of the