如何使用身份框架在管理员在MVC 5中添加用户时绕过电子邮件验证 [英] How to bypass email verification when a user is added by admin in MVC 5 using identity framework

查看:82
本文介绍了如何使用身份框架在管理员在MVC 5中添加用户时绕过电子邮件验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



i有一个带有身份框架的MVC 5应用程序,当新用户注册到应用程序时我已经实现了电子邮件验证,但是当管理员创建一个新用户时我需要绕过它用户甚至电子邮件字段应该是可选的,因为我使用手机号码登录,我怎么能实现它请帮助。



提前谢谢



我尝试过的事情:



i直到现在才遇到任何解决方案

Hi,
i have a MVC 5 application with identity framework in which I have implemented email verification when a new user is registering to the application, however i need to bypass this when admin is creating a new user even email field should be optional as i am using mobile number to login, how i can achieve it please help.

Thank you in advance

What I have tried:

i have not came across any solution till now

推荐答案

实现一个派生自.net类中的SecurityProvider的类,并根据给定的用户类型对其进行自定义操作。



在用户登录时,检查此用户是否为管理员或其他用户,然后将aspnet身份安全上下文和提供程序重新加载到具有所需实现的相关类型。



查看此链接以获取有关其工作原理的一些信息,然后自定义策略的内部br />
ASP.NET Identity 2.0:设置帐户验证和双因素授权John Atten [ ^ ]
Implement a class which derives from the SecurityProvider in .net class and customise it to behave differently for given user type.

On user login, check if this user is admin or whatever, then re-load the aspnet identity security context and provider to the relevant type with the desired implementation.

Check this link for some info on how it works, then you customise the internals of the policies.
ASP.NET Identity 2.0: Setting Up Account Validation and Two-Factor Authorization | John Atten[^]


假设你有一个标志告诉是否用户拥有已注册的电子邮件。

在新用户的创建屏幕上,添加一个可选的CheckBox,用于判断电子邮件是否已注册。

可用的复选框(不隐藏)仅限管理员。
Assuming you have a flag telling if a user have a registered Email.
On the Create screen for new users, add an optional CheckBox that is used to tell if Email is registered.
The checkBox being available (not hidden) to Admin only.


这篇关于如何使用身份框架在管理员在MVC 5中添加用户时绕过电子邮件验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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