@page
@model Company.WebApplication1.Pages.Settings.SecurityModel
@{
    ViewData["Title"] = "Security";
}

<!-- Content Header (Page header) -->
<section class="content-header">
    <h1>
        My Profile
    </h1>
    <ol class="breadcrumb">
        <li><a href="/"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#">Settings</a></li>
        <li class="active">My Profile</li>
    </ol>
</section>


<!-- Main content -->
<section class="content">

    <div class="row">
        <div class="col-lg-2">

        </div>
        <!-- /.col -->

        <div class="col-lg-8">

            <h4>External Logins</h4>

            <ul class="list-group">
                @foreach (var login in Model.CurrentLogins)
                {
                    <li class="list-group-item">
                        <div class="row">
                            <div class="col-xs-4 text-left nowrap">
                                <span class="btn btn-social-icon btn-@login.LoginProvider.ToLower()">
                                    <i class="fa fa-@login.LoginProvider.ToLower()"></i>
                                </span>
                                <strong>@login.ProviderDisplayName</strong> <span class="label label-primary">Connected</span>
                            </div>
                            <div class="col-xs-8 text-right">
                                @if (Model.ShowRemoveButton)
                                {
                                    <form asp-page-handler="RemoveLogin" method="post">
                                        <div>
                                            <input asp-for="@login.LoginProvider" name="LoginProvider" type="hidden" />
                                            <input asp-for="@login.ProviderKey" name="ProviderKey" type="hidden" />
                                            <button type="submit" class="btn btn-danger" title="Remove this @login.LoginProvider login from your account">
                                                <i class="fa fa-remove"></i> Disconnect
                                            </button>
                                        </div>
                                    </form>
                                }
                            </div>
                        </div>
                    </li>
                }
                @foreach (var provider in Model.OtherLogins)
                {
                    <li class="list-group-item">
                        <div class="row">
                            <div class="col-xs-4 text-left nowrap">
                                <span class="btn btn-social-icon btn-@provider.DisplayName.ToLower()">
                                    <i class="fa fa-@provider.DisplayName.ToLower()"></i>
                                </span>
                                <strong>@provider.DisplayName</strong>
                            </div>
                            <div class="col-xs-8 text-right">
                                <form asp-page-handler="LinkLogin" method="post" class="form-horizontal">
                                    <button type="submit" class="btn btn-primary" name="provider" value="@provider.Name">
                                        <i class="fa fa-plus"></i> Connect
                                    </button>
                                </form>
                            </div>
                        </div>
                    </li>
                }
            </ul>

            <h4>Two-factor authentication</h4>
            @if (Model.Is2faEnabled)
            {
                @if (Model.RecoveryCodesLeft == 0)
                {
                    <div class="alert alert-danger">
                        <strong>You have no recovery codes left.</strong>
                        <p>You must <a asp-page="./TwoFactorAuth/RecoveryCodes">generate a new set of recovery codes</a> before you can log in with a recovery code.</p>
                    </div>
                }
                else if (Model.RecoveryCodesLeft == 1)
                {
                    <div class="alert alert-danger">
                        <strong>You have 1 recovery code left.</strong>
                        <p>You can <a asp-page="./TwoFactorAuth/RecoveryCodes">generate a new set of recovery codes</a>.</p>
                    </div>
                }
                else if (Model.RecoveryCodesLeft <= 3)
                {
                    <div class="alert alert-warning">
                        <strong>You have @Model.RecoveryCodesLeft recovery codes left.</strong>
                        <p>You should <a asp-page="./TwoFactorAuth/RecoveryCodes">generate a new set of recovery codes</a>.</p>
                    </div>
                }
            }

            <ul class="list-group">

                <li class="list-group-item">
                    <div class="row">
                        @if (Model.Is2faEnabled)
                        {
                            <div class="col-xs-4 text-left nowrap">
                                Status: <span class="text-green"><strong>Enabled</strong> <i class="fa fa-check"></i></span>
                            </div>
                            <div class="col-xs-8 text-right">
                                <form asp-page-handler="Disable2FA" method="post" class="form-group">
                                    <a href="./TwoFactorAuth" class="btn btn-primary">
                                        <i class="fa fa-edit"></i> Edit
                                    </a>

                                    <button class="btn btn-danger" type="submit" title="Disable two-factor authentication"><i class="fa fa-remove"></i></button>
                                </form>
                            </div>
                        }
                        else
                        {
                            <div class="col-xs-4 text-left nowrap">
                                Status: <span class="text-red"><strong>Off</strong> <i class="fa fa-remove"></i></span>
                            </div>
                            <div class="col-xs-8 text-right">
                                <a href="./TwoFactorAuth" class="btn btn-primary">
                                    <i class="fa fa-lock"></i> Set up two-factor authentication
                                </a>
                            </div>
                        }
                    </div>
                </li>
                @if (Model.Is2faEnabled)
                {
                    <li class="list-group-item">
                        Save your <a href="./TwoFactorAuth/RecoveryCodes">recovery codes</a> in a safe place. They will allow you to access your account if you ever lose your phone.
                    </li>
                }
            </ul>

        </div>
        <!-- /.col -->

        <div class="col-lg-2">

        </div>
        <!-- /.col -->
    </div>
    <!-- /.row -->

</section>
<!-- /.content -->
