Browse Source

solve merge conflict

pull/1691/head
mehmet-erim 7 years ago
parent
commit
62bd583f22
  1. 30
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
  2. 15
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
  3. 2
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs
  4. 63
      framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs
  5. 2
      modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs
  6. 33
      npm/ng-packs/packages/core/src/lib/constants/different-locales.ts
  7. 1
      npm/ng-packs/packages/core/src/lib/constants/index.ts
  8. 12
      npm/ng-packs/packages/core/src/lib/core.module.ts
  9. 9
      npm/ng-packs/packages/core/src/lib/directives/ellipsis.directive.ts
  10. 1
      npm/ng-packs/packages/core/src/lib/providers/index.ts
  11. 24
      npm/ng-packs/packages/core/src/lib/providers/locale.provider.ts
  12. 44
      npm/ng-packs/packages/core/src/lib/services/localization.service.ts
  13. 14
      npm/ng-packs/packages/core/src/lib/states/config.state.ts
  14. 9
      npm/ng-packs/packages/core/src/lib/states/session.state.ts
  15. 26
      npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts
  16. 2
      npm/ng-packs/packages/core/src/public-api.ts
  17. 14
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html
  18. 16
      npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts
  19. 2
      npm/ng-packs/packages/tenant-management/src/lib/services/tenant-management.service.ts
  20. 1
      npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts
  21. 8
      npm/ng-packs/packages/theme-shared/src/lib/contants/styles.ts
  22. 3
      npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts

30
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs

@ -1,4 +1,5 @@
using System.IO;
using System;
using System.IO;
using System.Text;
using System.Threading.Tasks;
using IdentityModel;
@ -17,20 +18,25 @@ namespace Volo.Abp.Cli.Auth
AuthenticationService = authenticationService;
}
public async Task LoginAsync(string userName, string password)
public async Task LoginAsync(string userName, string password, string organizationName = null)
{
var accessToken = await AuthenticationService.GetAccessTokenAsync(
new IdentityClientConfiguration(
CliUrls.AccountAbpIo,
"role email abpio_www abpio_commercial",
"abp-cli",
"1q2w3e*",
OidcConstants.GrantTypes.Password,
userName,
password
)
var configuration = new IdentityClientConfiguration(
CliUrls.AccountAbpIo,
"role email abpio abpio_www abpio_commercial",
"abp-cli",
"1q2w3e*",
OidcConstants.GrantTypes.Password,
userName,
password
);
if (!organizationName.IsNullOrWhiteSpace())
{
configuration["[o]abp-organization-name"] = organizationName;
}
var accessToken = await AuthenticationService.GetAccessTokenAsync(configuration);
File.WriteAllText(CliPaths.AccessToken, accessToken, Encoding.UTF8);
}

15
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs

@ -44,7 +44,11 @@ namespace Volo.Abp.Cli.Commands
);
}
await AuthService.LoginAsync(commandLineArgs.Target, password);
await AuthService.LoginAsync(
commandLineArgs.Target,
password,
commandLineArgs.Options.GetOrNull(Options.Organization.Short, Options.Organization.Long)
);
Logger.LogInformation($"Successfully logged in as '{commandLineArgs.Target}'");
}
@ -70,5 +74,14 @@ namespace Volo.Abp.Cli.Commands
{
return string.Empty;
}
public static class Options
{
public static class Organization
{
public const string Short = "o";
public const string Long = "organization";
}
}
}
}

2
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityClientConfiguration.cs

@ -81,7 +81,7 @@ namespace Volo.Abp.IdentityModel
get => this.GetOrDefault(nameof(RequireHttps))?.To<bool>() ?? true;
set => this[nameof(RequireHttps)] = value.ToString().ToLowerInvariant();
}
public IdentityClientConfiguration()
{

63
framework/src/Volo.Abp.IdentityModel/Volo/Abp/IdentityModel/IdentityModelAuthenticationService.cs

@ -6,6 +6,7 @@ using Microsoft.Extensions.Logging.Abstractions;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Threading.Tasks;
@ -117,26 +118,12 @@ namespace Volo.Abp.IdentityModel
{
case OidcConstants.GrantTypes.ClientCredentials:
return await httpClient.RequestClientCredentialsTokenAsync(
new ClientCredentialsTokenRequest
{
Address = discoveryResponse.TokenEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret
},
await CreateClientCredentialsTokenRequestAsync(discoveryResponse, configuration),
CancellationTokenProvider.Token
);
case OidcConstants.GrantTypes.Password:
return await httpClient.RequestPasswordTokenAsync(
new PasswordTokenRequest
{
Address = discoveryResponse.TokenEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret,
UserName = configuration.UserName,
Password = configuration.UserPassword
},
await CreatePasswordTokenRequestAsync(discoveryResponse, configuration),
CancellationTokenProvider.Token
);
default:
@ -144,5 +131,49 @@ namespace Volo.Abp.IdentityModel
}
}
}
protected virtual Task<PasswordTokenRequest> CreatePasswordTokenRequestAsync(DiscoveryResponse discoveryResponse, IdentityClientConfiguration configuration)
{
var request = new PasswordTokenRequest
{
Address = discoveryResponse.TokenEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret,
UserName = configuration.UserName,
Password = configuration.UserPassword
};
AddParametersToRequestAsync(configuration, request);
return Task.FromResult(request);
}
protected virtual Task<ClientCredentialsTokenRequest> CreateClientCredentialsTokenRequestAsync(
DiscoveryResponse discoveryResponse,
IdentityClientConfiguration configuration)
{
var request = new ClientCredentialsTokenRequest
{
Address = discoveryResponse.TokenEndpoint,
Scope = configuration.Scope,
ClientId = configuration.ClientId,
ClientSecret = configuration.ClientSecret
};
AddParametersToRequestAsync(configuration, request);
return Task.FromResult(request);
}
protected virtual Task AddParametersToRequestAsync(IdentityClientConfiguration configuration, Request request)
{
foreach (var pair in configuration.Where(p => p.Key.StartsWith("[o]", StringComparison.OrdinalIgnoreCase)))
{
request.Parameters[pair.Key] = pair.Value;
}
return Task.CompletedTask;
}
}
}

2
modules/identityserver/src/Volo.Abp.IdentityServer.Domain/Volo/Abp/IdentityServer/AspNetIdentity/AbpResourceOwnerPasswordValidator.cs

@ -15,7 +15,7 @@ using Volo.Abp.Uow;
namespace Volo.Abp.IdentityServer.AspNetIdentity
{
public class AbpResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator //ResourceOwnerPasswordValidator<IdentityUser>
public class AbpResourceOwnerPasswordValidator : IResourceOwnerPasswordValidator
{
private readonly SignInManager<IdentityUser> _signInManager;
private readonly IEventService _events;

33
npm/ng-packs/packages/core/src/lib/constants/different-locales.ts

@ -0,0 +1,33 @@
// Different locales from .NET
// Key is .NET locale, value is Angular locale
export default {
'ar-sa': 'ar-SA',
'ca-ES-valencia': 'ca-ES-VALENCIA',
'de-de': 'de',
'es-ES': 'es',
'en-US': 'en',
'fil-Latn': 'en',
'ku-Arab': 'en',
'ky-Cyrl': 'en',
'mi-Latn': 'en',
'prs-Arab': 'en',
'qut-Latn': 'en',
nso: 'en',
quz: 'en',
'fr-FR': 'fr',
'gd-Latn': 'gd',
'ha-Latn': 'ha',
'ig-Latn': 'ig',
'it-it': 'it',
'mn-Cyrl': 'mn',
'pt-BR': 'pt',
'sd-Arab': 'pa-Arab',
'sr-Cyrl-RS': 'sr-Cyrl',
'sr-Latn-RS': 'sr-Latn',
'tg-Cyrl': 'tg',
'tk-Latn': 'tk',
'tt-Cyrl': 'tt',
'ug-Arab': 'ug',
'yo-Latn': 'yo',
};

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

@ -0,0 +1 @@
export * from './different-locales';

12
npm/ng-packs/packages/core/src/lib/core.module.ts

@ -18,11 +18,12 @@ import { VisibilityDirective } from './directives/visibility.directive';
import { ApiInterceptor } from './interceptors/api.interceptor';
import { ABP } from './models/common';
import { LocalizationPipe } from './pipes/localization.pipe';
import { ConfigPlugin, NGXS_CONFIG_PLUGIN_OPTIONS } from './plugins/config/config.plugin';
import { LocaleProvider } from './providers/locale.provider';
import { ConfigState } from './states/config.state';
import { ProfileState } from './states/profile.state';
import { SessionState } from './states/session.state';
import { getInitialData } from './utils/initial-utils';
import { getInitialData, localeInitializer } from './utils/initial-utils';
import { ConfigPlugin, NGXS_CONFIG_PLUGIN_OPTIONS } from './plugins/config/config.plugin';
@NgModule({
imports: [
@ -73,6 +74,7 @@ export class CoreModule {
return {
ngModule: CoreModule,
providers: [
LocaleProvider,
{
provide: NGXS_PLUGINS,
useClass: ConfigPlugin,
@ -93,6 +95,12 @@ export class CoreModule {
deps: [Injector],
useFactory: getInitialData,
},
{
provide: APP_INITIALIZER,
multi: true,
deps: [Injector],
useFactory: localeInitializer,
},
],
};
}

9
npm/ng-packs/packages/core/src/lib/directives/ellipsis.directive.ts

@ -14,14 +14,19 @@ export class EllipsisDirective implements AfterContentInit {
@Input('abpEllipsisEnabled')
enabled = true;
@HostBinding('class.abp-ellipsis-inline')
get inlineClass() {
return this.enabled && this.width;
}
@HostBinding('class.abp-ellipsis')
get class() {
return this.enabled;
return this.enabled && !this.width;
}
@HostBinding('style.max-width')
get maxWidth() {
return this.enabled ? this.width || '170px' : undefined;
return this.enabled && this.width ? this.width || '170px' : undefined;
}
constructor(private cdRef: ChangeDetectorRef, private elRef: ElementRef) {}

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

@ -0,0 +1 @@
export * from './locale.provider';

24
npm/ng-packs/packages/core/src/lib/providers/locale.provider.ts

@ -0,0 +1,24 @@
import { LOCALE_ID, Provider } from '@angular/core';
import localesMapping from '../constants/different-locales';
import { LocalizationService } from '../services/localization.service';
export class LocaleId extends String {
constructor(private localizationService: LocalizationService) {
super();
}
toString(): string {
const { currentLang } = this.localizationService;
return localesMapping[currentLang] || currentLang;
}
valueOf(): string {
return this.toString();
}
}
export const LocaleProvider: Provider = {
provide: LOCALE_ID,
useClass: LocaleId,
deps: [LocalizationService],
};

44
npm/ng-packs/packages/core/src/lib/services/localization.service.ts

@ -1,11 +1,45 @@
import { Injectable } from '@angular/core';
import { Store } from '@ngxs/store';
import { ConfigState } from '../states';
import { Observable } from 'rxjs';
import { Injectable, Optional, SkipSelf } from '@angular/core';
import { ActivatedRouteSnapshot, Router } from '@angular/router';
import { Actions, Store } from '@ngxs/store';
import { noop, Observable } from 'rxjs';
import { ConfigState } from '../states/config.state';
import { SessionState } from '../states/session.state';
import { registerLocale } from '../utils/initial-utils';
type ShouldReuseRoute = (future: ActivatedRouteSnapshot, curr: ActivatedRouteSnapshot) => boolean;
@Injectable({ providedIn: 'root' })
export class LocalizationService {
constructor(private store: Store) {}
get currentLang(): string {
return this.store.selectSnapshot(SessionState.getLanguage);
}
constructor(
private store: Store,
private router: Router,
private actions: Actions,
@Optional()
@SkipSelf()
otherInstance: LocalizationService,
) {
if (otherInstance) throw new Error('LocaleService should have only one instance.');
}
private setRouteReuse(reuse: ShouldReuseRoute) {
this.router.routeReuseStrategy.shouldReuseRoute = reuse;
}
registerLocale(locale: string) {
const { shouldReuseRoute } = this.router.routeReuseStrategy;
this.setRouteReuse(() => false);
this.router.navigated = false;
return registerLocale(locale).then(async () => {
await this.router.navigateByUrl(this.router.url).catch(noop);
this.setRouteReuse(shouldReuseRoute);
});
}
get(keys: string, ...interpolateParams: string[]): Observable<string> {
return this.store.select(ConfigState.getCopy(keys, ...interpolateParams));

14
npm/ng-packs/packages/core/src/lib/states/config.state.ts

@ -169,11 +169,15 @@ export class ConfigState {
...configuration,
}),
),
switchMap(configuration =>
this.store.selectSnapshot(SessionState.getLanguage)
? of(null)
: dispatch(new SetLanguage(snq(() => configuration.setting.values['Abp.Localization.DefaultLanguage']))),
),
switchMap(configuration => {
let defaultLang: string = configuration.setting.values['Abp.Localization.DefaultLanguage'];
if (defaultLang.includes(';')) {
defaultLang = defaultLang.split(';')[0];
}
return this.store.selectSnapshot(SessionState.getLanguage) ? of(null) : dispatch(new SetLanguage(defaultLang));
}),
);
}

9
npm/ng-packs/packages/core/src/lib/states/session.state.ts

@ -1,6 +1,9 @@
import { Action, Selector, State, StateContext } from '@ngxs/store';
import { SetLanguage, SetTenant } from '../actions/session.actions';
import { ABP, Session } from '../models';
import { GetAppConfiguration } from '../actions/config.actions';
import { LocalizationService } from '../services/localization.service';
import { from, combineLatest } from 'rxjs';
@State<Session.State>({
name: 'SessionState',
@ -17,13 +20,15 @@ export class SessionState {
return tenant;
}
constructor() {}
constructor(private localizationService: LocalizationService) {}
@Action(SetLanguage)
setLanguage({ patchState }: StateContext<Session.State>, { payload }: SetLanguage) {
setLanguage({ patchState, dispatch }: StateContext<Session.State>, { payload }: SetLanguage) {
patchState({
language: payload,
});
return combineLatest([dispatch(new GetAppConfiguration()), from(this.localizationService.registerLocale(payload))]);
}
@Action(SetTenant)

26
npm/ng-packs/packages/core/src/lib/utils/initial-utils.ts

@ -1,6 +1,9 @@
import { registerLocaleData } from '@angular/common';
import { Injector } from '@angular/core';
import { Store } from '@ngxs/store';
import { GetAppConfiguration } from '../actions/config.actions';
import differentLocales from '../constants/different-locales';
import { SessionState } from '../states/session.state';
export function getInitialData(injector: Injector) {
const fn = function() {
@ -11,3 +14,26 @@ export function getInitialData(injector: Injector) {
return fn;
}
export function localeInitializer(injector: Injector) {
const fn = function() {
const store: Store = injector.get(Store);
const lang = store.selectSnapshot(SessionState.getLanguage) || 'en';
return new Promise((resolve, reject) => {
registerLocale(lang).then(() => resolve(), reject);
});
};
return fn;
}
export function registerLocale(locale: string) {
return import(
/* webpackInclude: /(af|am|ar-SA|as|az-Latn|be|bg|bn-BD|bn-IN|bs|ca|ca-ES-VALENCIA|cs|cy|da|de|de|el|en-GB|en|es|en|es-US|es-MX|et|eu|fa|fi|en|fr|fr|fr-CA|ga|gd|gl|gu|ha|he|hi|hr|hu|hy|id|ig|is|it|it|ja|ka|kk|km|kn|ko|kok|en|en|lb|lt|lv|en|mk|ml|mn|mr|ms|mt|nb|ne|nl|nl-BE|nn|en|or|pa|pa-Arab|pl|en|pt|pt-PT|en|en|ro|ru|rw|pa-Arab|si|sk|sl|sq|sr-Cyrl-BA|sr-Cyrl|sr-Latn|sv|sw|ta|te|tg|th|ti|tk|tn|tr|tt|ug|uk|ur|uz-Latn|vi|wo|xh|yo|zh-Hans|zh-Hant|zu)\.js$/ */
`@angular/common/locales/${differentLocales[locale] || locale}.js`
).then(module => {
registerLocaleData(module.default);
});
}

2
npm/ng-packs/packages/core/src/public-api.ts

@ -5,7 +5,7 @@
// export * from './lib/handlers';
export * from './lib/actions';
export * from './lib/components';
// export * from './lib/constants';
export * from './lib/constants';
export * from './lib/directives';
export * from './lib/enums';
export * from './lib/guards';

14
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.html

@ -127,22 +127,22 @@
<ng-template #connectionStringModalTemplate>
<form [formGroup]="defaultConnectionStringForm" (ngSubmit)="save()">
<div class="mt-2">
<label class="mt-2">
<div class="form-group">
<div class="form-check">
<div class="custom-checkbox custom-control mb-2">
<input
id="useSharedDatabase"
type="checkbox"
class="form-check-input"
class="custom-control-input"
formControlName="useSharedDatabase"
autofocus
/>
<label for="useSharedDatabase" class="font-check-label">{{
<label for="useSharedDatabase" class="custom-control-label">{{
'AbpTenantManagement::DisplayName:UseSharedDatabase' | abpLocalization
}}</label>
</div>
</div>
<div class="form-group" *ngIf="!useSharedDatabase">
<label class="form-group" *ngIf="!useSharedDatabase">
<label for="defaultConnectionString">{{
'AbpTenantManagement::DisplayName:DefaultConnectionString' | abpLocalization
}}</label>
@ -152,8 +152,8 @@
class="form-control"
formControlName="defaultConnectionString"
/>
</div>
</div>
</label>
</label>
</form>
</ng-template>

16
npm/ng-packs/packages/tenant-management/src/lib/components/tenants/tenants.component.ts

@ -93,7 +93,7 @@ export class TenantsComponent {
private createDefaultConnectionStringForm() {
this.defaultConnectionStringForm = this.fb.group({
useSharedDatabase: this._useSharedDatabase,
defaultConnectionString: this.defaultConnectionString || '',
defaultConnectionString: [this.defaultConnectionString || ''],
});
}
@ -151,20 +151,24 @@ export class TenantsComponent {
saveConnectionString() {
this.modalBusy = true;
if (this.useSharedDatabase) {
if (this.useSharedDatabase || (!this.useSharedDatabase && !this.connectionString)) {
this.tenantService
.deleteDefaultConnectionString(this.selected.id)
.pipe(take(1))
.pipe(
take(1),
finalize(() => (this.modalBusy = false)),
)
.subscribe(() => {
this.modalBusy = false;
this.isModalVisible = false;
});
} else {
this.tenantService
.updateDefaultConnectionString({ id: this.selected.id, defaultConnectionString: this.connectionString })
.pipe(take(1))
.pipe(
take(1),
finalize(() => (this.modalBusy = false)),
)
.subscribe(() => {
this.modalBusy = false;
this.isModalVisible = false;
});
}

2
npm/ng-packs/packages/tenant-management/src/lib/services/tenant-management.service.ts

@ -83,7 +83,7 @@ export class TenantManagementService {
}
deleteDefaultConnectionString(id: string): Observable<string> {
const url = `/api/multi-tenancy/tenant/${id}/default-connection-string`;
const url = `/api/multi-tenancy/tenants/${id}/default-connection-string`;
const request: Rest.Request<TenantManagement.DefaultConnectionStringRequest> = {
method: 'DELETE',

1
npm/ng-packs/packages/theme-basic/src/lib/components/application-layout/application-layout.component.ts

@ -147,7 +147,6 @@ export class ApplicationLayoutComponent implements AfterViewInit, OnDestroy {
onChangeLang(cultureName: string) {
this.store.dispatch(new SetLanguage(cultureName));
this.store.dispatch(new GetAppConfiguration());
}
logout() {

8
npm/ng-packs/packages/theme-shared/src/lib/contants/styles.ts

@ -32,13 +32,19 @@ export default `
background-color: rgba(0, 0, 0, .6);
}
.abp-ellipsis {
.abp-ellipsis-inline {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.abp-ellipsis {
overflow: hidden !important;
text-overflow: ellipsis;
white-space: nowrap;
}
/* <animations */
.fade-in-top {

3
npm/ng-packs/packages/theme-shared/src/lib/theme-shared.module.ts

@ -1,6 +1,5 @@
import { CoreModule, LazyLoadService } from '@abp/ng.core';
import { APP_INITIALIZER, Injector, ModuleWithProviders, NgModule } from '@angular/core';
import { NgbModalModule } from '@ng-bootstrap/ng-bootstrap';
import { NgxValidateCoreModule } from '@ngx-validate/core';
import { MessageService } from 'primeng/components/common/messageservice';
import { ToastModule } from 'primeng/toast';
@ -40,7 +39,6 @@ export function appendScript(injector: Injector) {
imports: [
CoreModule,
ToastModule,
NgbModalModule,
NgxValidateCoreModule.forRoot({
targetSelector: '.form-group',
blueprints: {
@ -67,7 +65,6 @@ export function appendScript(injector: Injector) {
ProfileComponent,
],
exports: [
NgbModalModule,
ButtonComponent,
ConfirmationComponent,
ToastComponent,

Loading…
Cancel
Save