How to customize Asp.Net Core 2.1 login screen

Asked

Viewed 362 times

0

With the following service settings below I can login to Twitter, Hotmail, Facebook.

Noting that my project at the time of creation enabled the individual login option

services.AddAuthentication()
        .AddTwitter(twitterOptions =>
        {
           twitterOptions.ConsumerKey = "#######";
           twitterOptions.ConsumerSecret = "#######";
            })
        .AddFacebook(facebookOptions => 
        {
           facebookOptions.AppId = "#######";
           facebookOptions.AppSecret = "#######";
         })
         .AddMicrosoftAccount(microsoftOptions =>
         {
            microsoftOptions.ClientId = "#######";
            microsoftOptions.ClientSecret = "#######";
         });

With the service settings performed:

  • I want to create a page that will be the initial
  • The home page will only have logins Buttons through social networks
  • Example of the page I wish to do this just below.

The question is:

How do I set up buttons with social media images inside a custom page in Asp.Net Core 2.1 for logging

In Asp.Net MVC has the following configuration within the _ExternalLoginListPartial.cshtml

 @using Microsoft.Owin.Security
 @foreach (AuthenticationDescription p in loginProviders) 
 {
     <button type="submit" class="btn btn-default" id="@p.AuthenticationType" name="provider" value="@p.AuthenticationType" title="Faça login usando sua conta @p.Caption">@p.AuthenticationType</button>
 }

inserir a descrição da imagem aqui

1 answer

0

Friend, I didn’t understand your question very well, but you can do the following:

  1. In the open project, right-click on it, then Add and then New Scaffolded Item, as below:

inserir a descrição da imagem aqui 2. On the new screen, choose Identity and then the Login and Externallogin views, ready, now customize.

inserir a descrição da imagem aqui

inserir a descrição da imagem aqui

In fact you need to use Signinmanager.Getexternalauthenticationschemesasync() to get the schemas and then use it on your buttons and make a Submit for Externallogin. But look at the generated files that I believe is easy.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.