配置Microsoft.AspNet.Identity允许电子邮件地址作为用户名 [英] Configure Microsoft.AspNet.Identity to allow email address as username

查看:1430
本文介绍了配置Microsoft.AspNet.Identity允许电子邮件地址作为用户名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在创建一个新的应用程序的过程,并开始使用的EF6-RC1,Microsoft.AspNet.Identity.Core 1.0.0-RC1,Microsoft.AspNet.Identity.EntityFramework 1.0.0-RC1,微软。 AspNet.Identity.Owin 1.0.0-RC1等,并与RTM版本,昨天我经过的NuGet今天晚上更新他们RTM。

I'm in the process of creating a new application and started out using EF6-rc1, Microsoft.AspNet.Identity.Core 1.0.0-rc1, Microsoft.AspNet.Identity.EntityFramework 1.0.0-rc1, Microsoft.AspNet.Identity.Owin 1.0.0-rc1, etc and with the RTM releases yesterday, I updated them via NuGet this evening to RTM.

除了一对夫妇code更改工作我迄今所做的,一切似乎都很顺利,直到我试图为应用程序创建一个本地用户帐户。

Apart from a couple of code changes to the work I'd done so far, all seemed to be going well, until I tried to create a local user account for the app.

我一直在努力的电子邮件地址作为用户名格式,它与发布候选伟大的工作,但现在创建一个电子邮件地址作为用户名的用户时,抛出了以下验证错误:

I had been working on e-mail addresses being the username format which with the release candidate worked great, but now when creating a user with an email address for a username, it throws up the following validation error:

User name xxxxx@xxxx.com is invalid, can only contain letters or digits.

我花了最后一个小时左右寻找关于它的配置选项的解决办法或文件,但无济于事。

I've spent the last hour or so searching for a solution or documentation on configuration options for it, but to no avail.

有没有一种方法,我可以配置它允许用户名电子邮件地址?

Is there a way I can configure it to allow e-mail addresses for usernames?

推荐答案

您可以通过在上的UserManager自己UserValidator堵塞,或只是将其关闭的默认实现允许这种

You can allow this by plugging in your own UserValidator on the UserManager, or just by turning it off on the default implementation:

UserManager.UserValidator = new UserValidator<TUser>(UserManager) { AllowOnlyAlphanumericUserNames = false }

这篇关于配置Microsoft.AspNet.Identity允许电子邮件地址作为用户名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆