Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(account): add the enableLocalLogin condition to auth-wrapper #2573

Merged
merged 2 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ public override void Define(ISettingDefinitionContext context)
AccountSettingNames.IsSelfRegistrationEnabled,
"true",
L("DisplayName:Abp.Account.IsSelfRegistrationEnabled"),
L("Description:Abp.Account.IsSelfRegistrationEnabled"))
L("Description:Abp.Account.IsSelfRegistrationEnabled"), isVisibleToClients : true)
);

context.Add(
new SettingDefinition(
AccountSettingNames.EnableLocalLogin,
"true",
L("DisplayName:Abp.Account.EnableLocalLogin"),
L("Description:Abp.Account.EnableLocalLogin"))
L("Description:Abp.Account.EnableLocalLogin"), isVisibleToClients : true)
);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
@page
@using Volo.Abp.Account.Settings
@using Volo.Abp.Settings
@model Volo.Abp.Account.Web.Pages.Account.LoginModel
@inherits Volo.Abp.Account.Web.Pages.Account.AccountPage
@inject Volo.Abp.Settings.ISettingProvider SettingProvider
@if (Model.EnableLocalLogin)
{
<div class="card mt-3 shadow-sm rounded">
<div class="card-body p-5">
<h4>@L["Login"]</h4>
@if (string.Equals(await SettingProvider.GetOrNullAsync(AccountSettingNames.IsSelfRegistrationEnabled), "true", StringComparison.OrdinalIgnoreCase))
<h4>@L["Login"]</h4>
@if (await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled))
{
<strong>
@L["AreYouANewUser"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ public virtual async Task<IActionResult> OnPostAsync()

protected virtual async Task CheckSelfRegistrationAsync()
{
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false))
if (!await SettingProvider.IsTrueAsync(AccountSettingNames.IsSelfRegistrationEnabled).ConfigureAwait(false) ||
!await SettingProvider.IsTrueAsync(AccountSettingNames.EnableLocalLogin).ConfigureAwait(false))
{
throw new UserFriendlyException(L["SelfRegistrationDisabledMessage"]);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
></abp-tenant-box>

<div class="abp-account-container">
<div class="card mt-3 shadow-sm rounded">
<div
*ngIf="(enableLocalLogin$ | async) !== 'False'; else disableLocalLoginTemplate"
class="card mt-3 shadow-sm rounded"
>
<div class="card-body p-5">
<ng-content *ngTemplateOutlet="mainContentRef"></ng-content>
</div>
Expand All @@ -14,3 +17,10 @@
</div>
</div>
</div>

<ng-template #disableLocalLoginTemplate>
<div class="alert alert-warning">
<strong>{{ 'AbpAccount::InvalidLoginRequest' | abpLocalization }}</strong>
{{ 'AbpAccount::ThereAreNoLoginSchemesConfiguredForThisClient' | abpLocalization }}
</div>
</ng-template>
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import { Component, Input, TemplateRef } from '@angular/core';
import { Account } from '../../models/account';
import { Select } from '@ngxs/store';
import { ConfigState } from '@abp/ng.core';
import { Observable } from 'rxjs';

@Component({
selector: 'abp-auth-wrapper',
Expand All @@ -8,6 +11,9 @@ import { Account } from '../../models/account';
})
export class AuthWrapperComponent
implements Account.AuthWrapperComponentInputs, Account.AuthWrapperComponentOutputs {
@Select(ConfigState.getSetting('Abp.Account.EnableLocalLogin'))
enableLocalLogin$: Observable<'True' | 'False'>;

@Input()
readonly mainContentRef: TemplateRef<any>;

Expand Down