Browse Source

Merge branch 'dev' of https://github.com/abpframework/abp into Password-Flow-TwoFactor

pull/9176/head
mehmet-erim 5 years ago
parent
commit
f03b47ab47
  1. 1981
      docs/en/Domain-Driven-Design-Implementation-Guide.md
  2. 2
      docs/en/UI/Blazor/Overall.md
  3. 4
      docs/en/docs-nav.json
  4. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/InstallLibsCommand.cs
  5. 2
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/LIbs/IInstallLibsService.cs
  6. 13
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/LIbs/InstallLibsService.cs
  7. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/index.js
  8. 6
      npm/ng-packs/packages/core/src/lib/models/auth.ts
  9. 1
      npm/ng-packs/packages/core/src/lib/models/index.ts
  10. 7
      npm/ng-packs/packages/core/src/lib/services/auth.service.ts
  11. 41
      npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts
  12. 41
      npm/ng-packs/packages/core/src/lib/utils/auth-utils.ts
  13. 20
      npm/ng-packs/packages/core/src/lib/utils/http-utils.ts
  14. 1
      npm/ng-packs/packages/core/src/lib/utils/index.ts

1981
docs/en/Domain-Driven-Design-Implementation-Guide.md

File diff suppressed because it is too large

2
docs/en/UI/Blazor/Overall.md

@ -93,6 +93,8 @@ These libraries are selected as the base libraries and available to the applicat
> Bootstrap's JavaScript part is not used since the Blazorise library already provides the necessary functionalities to the Bootstrap components in a native way.
> Beginning from June, 2021, the Blazorise library has dual licenses; open source & commercial. Based on your yearly revenue, you may need to buy a commercial license. See [this post](https://blazorise.com/news/blazorise-commercial-going-live/) for the announcement.
### The Layout
The themes provide the layout. So, you have a responsive layout with the standard features already implemented. The screenshot below has taken from the layout of the [Basic Theme](Basic-Theme.md):

4
docs/en/docs-nav.json

@ -543,8 +543,8 @@
]
},
{
"text": "Guide: Implementing DDD",
"path": "Domain-Driven-Design-Implementation-Guide.md"
"text": "E-Book: Implementing DDD",
"path": "https://abp.io/books/implementing-domain-driven-design"
}
]
},

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/InstallLibsCommand.cs

@ -40,7 +40,7 @@ namespace Volo.Abp.Cli.Commands
);
}
await InstallLibsService.InstallLibs(workingDirectory);
await InstallLibsService.InstallLibsAsync(workingDirectory);
}
public string GetUsageInfo()

2
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/LIbs/IInstallLibsService.cs

@ -4,6 +4,6 @@ namespace Volo.Abp.Cli.LIbs
{
public interface IInstallLibsService
{
Task InstallLibs(string directory);
Task InstallLibsAsync(string directory);
}
}

13
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/LIbs/InstallLibsService.cs

@ -16,6 +16,8 @@ namespace Volo.Abp.Cli.LIbs
{
public class InstallLibsService : IInstallLibsService, ITransientDependency
{
public const string LibsDirectory = "./wwwroot/libs";
public ILogger<InstallLibsService> Logger { get; set; }
private readonly IJsonSerializer _jsonSerializer;
@ -26,7 +28,7 @@ namespace Volo.Abp.Cli.LIbs
Logger = NullLogger<InstallLibsService>.Instance;
}
public async Task InstallLibs(string directory)
public async Task InstallLibsAsync(string directory)
{
var projectFiles = Directory.GetFiles(directory, "*.csproj");
if (!projectFiles.Any())
@ -65,7 +67,7 @@ namespace Volo.Abp.Cli.LIbs
var mappingFiles = Directory.GetFiles(fileDirectory, "abp.resourcemapping.js", SearchOption.AllDirectories);
var resourceMapping = new ResourceMapping
{
Clean = new List<string> {"./wwwroot/libs"}
Clean = new List<string> {LibsDirectory}
};
foreach (var mappingFile in mappingFiles)
@ -92,10 +94,17 @@ namespace Volo.Abp.Cli.LIbs
}
}
EnsureLibsFolderExists(fileDirectory, LibsDirectory);
CleanDirsAndFiles(fileDirectory, resourceMapping);
CopyResourcesToLibs(fileDirectory, resourceMapping);
}
private void EnsureLibsFolderExists(string fileDirectory, string libsDirectory)
{
Directory.CreateDirectory(Path.Combine(fileDirectory, libsDirectory));
}
private void CopyResourcesToLibs(string fileDirectory, ResourceMapping resourceMapping)
{
foreach (var mapping in resourceMapping.Mappings)

6
modules/cms-kit/src/Volo.CmsKit.Admin.Web/Pages/CmsKit/BlogPosts/index.js

@ -28,14 +28,14 @@ $(function () {
items: [
{
text: l('Edit'),
visible: abp.auth.isGranted('CmsKit.Blogs.Update'),
visible: abp.auth.isGranted('CmsKit.BlogPosts.Update'),
action: function (data) {
location.href = "BlogPosts/Update/" + data.record.id
}
},
{
text: l('Delete'),
visible: abp.auth.isGranted('CmsKit.Blogs.Delete'),
visible: abp.auth.isGranted('CmsKit.BlogPosts.Delete'),
confirmMessage: function (data) {
return l("BlogPostDeletionConfirmationMessage", data.record.title)
},
@ -83,4 +83,4 @@ $(function () {
e.preventDefault();
window.location.href = "BlogPosts/Create"
});
});
});

6
npm/ng-packs/packages/core/src/lib/models/auth.ts

@ -0,0 +1,6 @@
export interface LoginParams {
username: string;
password: string;
rememberMe?: boolean;
redirectUrl?: string;
}

1
npm/ng-packs/packages/core/src/lib/models/index.ts

@ -1,4 +1,5 @@
export * from './application-configuration';
export * from './auth';
export * from './common';
export * from './config';
export * from './dtos';

7
npm/ng-packs/packages/core/src/lib/services/auth.service.ts

@ -2,11 +2,8 @@ import { Injectable, Injector } from '@angular/core';
import { Params } from '@angular/router';
import { from, Observable } from 'rxjs';
import { filter, map, switchMap, take, tap } from 'rxjs/operators';
import {
AuthFlowStrategy,
AUTH_FLOW_STRATEGY,
LoginParams,
} from '../strategies/auth-flow.strategy';
import { LoginParams } from '../models/auth';
import { AuthFlowStrategy, AUTH_FLOW_STRATEGY } from '../strategies/auth-flow.strategy';
import { EnvironmentService } from './environment.service';
@Injectable({

41
npm/ng-packs/packages/core/src/lib/strategies/auth-flow.strategy.ts

@ -9,22 +9,17 @@ import {
OAuthService,
OAuthStorage,
} from 'angular-oauth2-oidc';
import { from, Observable, of } from 'rxjs';
import { from, Observable, of, pipe } from 'rxjs';
import { filter, switchMap, tap } from 'rxjs/operators';
import { RestOccurError } from '../actions/rest.actions';
import { LoginParams } from '../models/auth';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { ConfigStateService } from '../services/config-state.service';
import { EnvironmentService } from '../services/environment.service';
import { SessionStateService } from '../services/session-state.service';
import { removeRememberMe, setRememberMe } from '../utils/auth-utils';
import { noop } from '../utils/common-utils';
export interface LoginParams {
username: string;
password: string;
rememberMe?: boolean;
redirectUrl?: string;
}
export const oAuthStorage = localStorage;
export abstract class AuthFlowStrategy {
@ -145,7 +140,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
this.refreshToken();
} else {
this.oAuthService.logOut();
this.removeRememberMe();
removeRememberMe();
this.appConfigService.get().subscribe(res => {
this.configState.setState(res);
});
@ -153,19 +148,6 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
});
}
private setRememberMe(remember: boolean) {
this.removeRememberMe();
localStorage.setItem(this.storageKey, 'true');
document.cookie = `${this.cookieKey}=true; path=/${
remember ? ' ;expires=Fri, 31 Dec 9999 23:59:59 GMT' : ''
}`;
}
private removeRememberMe() {
localStorage.removeItem(this.storageKey);
document.cookie = this.cookieKey + '= ; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT';
}
async init() {
if (!getCookieValueByName(this.cookieKey) && localStorage.getItem(this.storageKey)) {
this.oAuthService.logOut();
@ -184,7 +166,6 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
}
login(params: LoginParams): Observable<any> {
const router = this.injector.get(Router);
const tenant = this.sessionState.getTenant();
return from(
@ -193,11 +174,17 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
params.password,
new HttpHeaders({ ...(tenant && tenant.id && { __tenant: tenant.id }) }),
),
).pipe(
).pipe(this.pipeToLogin(params));
}
pipeToLogin(params: Pick<LoginParams, 'redirectUrl' | 'rememberMe'>) {
const router = this.injector.get(Router);
return pipe(
switchMap(() => this.appConfigService.get()),
tap(res => {
this.configState.setState(res);
this.setRememberMe(params.rememberMe);
setRememberMe(params.rememberMe);
if (params.redirectUrl) router.navigate([params.redirectUrl]);
}),
);
@ -211,7 +198,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
tap(res => {
this.configState.setState(res);
router.navigateByUrl('/');
this.removeRememberMe();
removeRememberMe();
}),
);
}
@ -219,7 +206,7 @@ export class AuthPasswordFlowStrategy extends AuthFlowStrategy {
protected refreshToken() {
return this.oAuthService.refreshToken().catch(() => {
clearOAuthStorage();
this.removeRememberMe();
removeRememberMe();
});
}
}

41
npm/ng-packs/packages/core/src/lib/utils/auth-utils.ts

@ -0,0 +1,41 @@
import { Injector } from '@angular/core';
import { Router } from '@angular/router';
import { pipe } from 'rxjs';
import { switchMap, tap } from 'rxjs/operators';
import { LoginParams } from '../models/auth';
import { AbpApplicationConfigurationService } from '../proxy/volo/abp/asp-net-core/mvc/application-configurations/abp-application-configuration.service';
import { ConfigStateService } from '../services/config-state.service';
const cookieKey = 'rememberMe';
const storageKey = 'passwordFlow';
export function pipeToLogin(
params: Pick<LoginParams, 'redirectUrl' | 'rememberMe'>,
injector: Injector,
) {
const configState = injector.get(ConfigStateService);
const appConfigService = injector.get(AbpApplicationConfigurationService);
const router = injector.get(Router);
return pipe(
switchMap(() => appConfigService.get()),
tap(res => {
configState.setState(res);
setRememberMe(params.rememberMe);
if (params.redirectUrl) router.navigate([params.redirectUrl]);
}),
);
}
export function setRememberMe(remember: boolean) {
removeRememberMe();
localStorage.setItem(storageKey, 'true');
document.cookie = `${cookieKey}=true; path=/${
remember ? ' ;expires=Fri, 31 Dec 9999 23:59:59 GMT' : ''
}`;
}
export function removeRememberMe() {
localStorage.removeItem(storageKey);
document.cookie = cookieKey + '= ; path=/; expires = Thu, 01 Jan 1970 00:00:00 GMT';
}

20
npm/ng-packs/packages/core/src/lib/utils/http-utils.ts

@ -1,4 +1,24 @@
import { HttpParameterCodec } from '@angular/common/http';
export function getPathName(url: string): string {
const { pathname } = new URL(url, window.location.origin);
return pathname;
}
export class WebHttpUrlEncodingCodec implements HttpParameterCodec {
encodeKey(k: string): string {
return encodeURIComponent(k);
}
encodeValue(v: string): string {
return encodeURIComponent(v);
}
decodeKey(k: string): string {
return decodeURIComponent(k);
}
decodeValue(v: string) {
return decodeURIComponent(v);
}
}

1
npm/ng-packs/packages/core/src/lib/utils/index.ts

@ -1,4 +1,5 @@
export * from './array-utils';
export * from './auth-utils';
export * from './common-utils';
export * from './date-utils';
export * from './environment-utils';

Loading…
Cancel
Save