简体   繁体   English

关联您的 Microsoft 帐户。 Email 条目。 一次又一次

[英]Associate your Microsoft account. Email entry. Again and Again

I just put together a.Net Core App via the documentation that authenticates with an Azure Active Directory.我只是通过使用 Azure Active Directory 进行身份验证的文档将 a.Net Core 应用程序放在一起。

https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/microsoft-logins?view=aspnetcore-5.0 https://docs.microsoft.com/en-us/aspnet/core/security/authentication/social/microsoft-logins?view=aspnetcore-5.0

I created and linked up the app id and secret, works great, but I'm trying to understand the behavior.我创建并链接了应用程序 ID 和密码,效果很好,但我试图了解这种行为。

When I first log in, it asks me to associate an email with the account.当我第一次登录时,它要求我将 email 与该帐户相关联。 Why is this?为什么是这样? My understanding, based on the database, is that you can log in without a real user presence on the internal user membership database.我的理解是,基于数据库,您可以在内部用户成员数据库上没有真实用户的情况下登录。 A soft authentication, so to say.可以这么说,是一种软身份验证。

When you, associate the user with an email it will create a membership record, that you can associate with roles.当您将用户与 email 关联时,它将创建一个成员记录,您可以将其与角色关联。

  1. Why the bifurcation...after isn't it my desire to create them as a user automatically with the same username?为什么分叉......之后我不是希望使用相同的用户名自动将它们创建为用户吗?

  2. After I've created the user and logged in a second time, why does the app "out of the box", ask them to associate an email address a second time?创建用户并第二次登录后,为什么应用程序“开箱即用”,要求他们第二次关联 email 地址? Which will simply error out as a duplicate entry.这将简单地作为重复条目出错。 Shouldn't the view check if the user exists first before displaying that text?视图不应该在显示该文本之前先检查用户是否存在吗?

I know I can make changes in code to get this behavior working more properly, but I suspect I'm missing something critical here.我知道我可以更改代码以使这种行为更正常地工作,但我怀疑我在这里遗漏了一些关键的东西。

Most importantly, I can attempt to hack it and automatically log them in and bypass this email step, but is there a way to do this via a setting?最重要的是,我可以尝试破解它并自动登录并绕过这个 email 步骤,但是有没有办法通过设置来做到这一点?

Thanks!谢谢!

The tutorial you are following sets options.SignIn.RequireConfirmedAccount = true , try setting false as below to skip confirmation.您正在遵循的教程设置options.SignIn.RequireConfirmedAccount = true ,尝试如下设置false以跳过确认。

public void ConfigureServices(IServiceCollection services)
{
    services.AddDbContext<ApplicationDbContext>(options =>
        options.UseSqlServer(
            Configuration.GetConnectionString("DefaultConnection")));
    services.AddDefaultIdentity<IdentityUser>(options => options.SignIn.RequireConfirmedAccount = false)
        .AddEntityFrameworkStores<ApplicationDbContext>();
    services.AddRazorPages();

    services.AddAuthentication().AddMicrosoftAccount(microsoftOptions =>
    {
        microsoftOptions.ClientId = Configuration["Authentication:Microsoft:ClientId"];
        microsoftOptions.ClientSecret = Configuration["Authentication:Microsoft:ClientSecret"];
    });
}

Associating an email with the account should be expected behavior.将 email 与帐户关联应该是预期的行为。

Now that you have chosen use Individual User Accounts to sign into your.Net Core App, although you sign in with an Microsoft account, there is not a individual User Account in the app currently.现在您已选择使用个人用户帐户登录您的 .Net Core 应用程序,虽然您使用 Microsoft 帐户登录,但该应用程序中目前没有个人用户帐户。

You still need to be redirected back to the web site where you can set your email, which is recognized as a individual User Account.您仍然需要被重定向回 web 站点,您可以在其中设置您的 email,该站点被识别为个人用户帐户。 See reference here .请参阅此处的参考。

  1. Why the bifurcation...after isn't it my desire to create them as a user automatically with the same username?为什么分叉......之后我不是希望使用相同的用户名自动将它们创建为用户吗?

Maybe your idea is reasonable, but there will be users who use emails different from Microsoft accounts.也许你的想法是合理的,但是会有用户使用不同于微软帐户的电子邮件。 And not all AAD work accounts have mailbox if they don't have O365 subscription with Exchange Online license.如果 AAD 工作帐户没有使用 Exchange Online 许可证的 O365 订阅,则并非所有 AAD 工作帐户都有邮箱。 In this case they have to use another different email.在这种情况下,他们必须使用另一个不同的 email。

  1. After I've created the user and logged in a second time, why does the app "out of the box", ask them to associate an email address a second time?创建用户并第二次登录后,为什么应用程序“开箱即用”,要求他们第二次关联 email 地址? Which will simply error out as a duplicate entry.这将简单地作为重复条目出错。 Shouldn't the view check if the user exists first before displaying that text?视图不应该在显示该文本之前先检查用户是否存在吗?

It is because that you didn't confirm your account .这是因为您没有确认您的帐户 When you first create the user (click on Register after sign in with Microsoft account), you are redirected to the to /Identity/Account/RegisterConfirmation page which contains a link to simulate email confirmation:当您首次创建用户时(使用 Microsoft 帐户登录后单击注册),您将被重定向到/Identity/Account/RegisterConfirmation页面,其中包含模拟 email 确认的链接:

  1. Select the Click here to confirm your account link . Select Click here to confirm your account link
  2. Select the Login link and sign-in with the same credentials. Select登录链接并使用相同的凭据登录。

Then you won't be required to Register any more.那么您将不再需要注册

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 再次强调服装输入 - underline costum entry again Microsoft Graph个人帐户。 如何获取用户照片? - Microsoft Graph personal account. How to get the users photo? 无法使用G Suit帐户通过smtp发送电子邮件。 - Can not send email by smtp using G Suit account. ASP.NET CORE - 发送电子邮件:请通过您的网络浏览器登录,然后重试 - ASP.NET CORE - Send email: Please log in via your web browser and then try again Microsoft身份验证自动登录帐户。 用户手动选择帐户时导致“关联失败”错误 - Microsoft authentication automatically signing in account. Causing “Correlation failed” error when user manually selects account 如何删除 MS LUIS 帐户并使用相同帐户重新创建 - How to delete MS LUIS account and create again with same account 如何确定电子邮件地址是Microsoft“工作或学校”帐户还是Microsoft帐户 - How to determine if an email address is a Microsoft 'Work or School' account or a Microsoft Account 您的登录尝试失败。 请再试一次 - Your login attempt was not successful. Please try again Microsoft Bot Framework:在不重新启动对话框的情况下再次询问 - Microsoft Bot Framework: Ask again without restarting dialog 获取Microsoft Live帐户的电子邮件地址 - Get email address of Microsoft Live account
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM