@page
@using Microsoft.AspNetCore.Authentication
@model ExternalLoginsModel
@{
    ViewData["Title"]      = "Manage your external logins";
    ViewData["ActivePage"] = ManageNavPages.ExternalLogins;
}
<partial for="StatusMessage" name="_StatusMessage"/>
@if(Model.CurrentLogins?.Count > 0)
{
    <h4>Registered Logins</h4>
    <table class="table">
        <tbody>
        @foreach(UserLoginInfo login in Model.CurrentLogins)
        {
            <tr>
                <td id="@($"login-provider-{login.LoginProvider}")">@login.ProviderDisplayName</td>
                <td>
                    @if(Model.ShowRemoveButton)
                    {
                        <form asp-page-handler="RemoveLogin" id="@($"remove-login-{login.LoginProvider}")"
                              method="post">
                            <div>
                                <input asp-for="@login.LoginProvider" name="LoginProvider" type="hidden"/>
                                <input asp-for="@login.ProviderKey" name="ProviderKey" type="hidden"/>
                                <button class="btn btn-primary"
                                        title="Remove this @login.ProviderDisplayName login from your account"
                                        type="submit">Remove
                                </button>
                            </div>
                        </form>
                    }
                    else
                    {
                        @: &nbsp;
                    }
                </td>
            </tr>
        }
        </tbody>
    </table>
}
@if(Model.OtherLogins?.Count > 0)
{
    <h4>Add another service to log in.</h4>
    <hr/>

    <form asp-page-handler="LinkLogin" class="form-horizontal" id="link-login-form" method="post">
        <div id="socialLoginList">
            <p>
                @foreach(AuthenticationScheme provider in Model.OtherLogins)
                {
                    <button class="btn btn-primary" id="@($"link-login-button-{provider.Name}")" name="provider"
                            title="Log in using your @provider.DisplayName account" type="submit"
                            value="@provider.Name">@provider.DisplayName</button>
                }
            </p>
        </div>
    </form>
}