Skip to content

Commit

Permalink
Merge pull request #2573 from abpframework/feat/implement-enable-loca…
Browse files Browse the repository at this point in the history
…l-login

feat(account): add the enableLocalLogin condition to auth-wrapper
  • Loading branch information
mehmet-erim authored Jan 7, 2020
2 parents 789b3d3 + 4ed7d57 commit 02c1b02
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 6 deletions.
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

0 comments on commit 02c1b02

Please sign in to comment.