mirror of https://github.com/abpframework/abp.git
44 changed files with 702 additions and 205 deletions
@ -1,3 +1,32 @@ |
|||||
.post-desc { |
.post-desc { |
||||
overflow-wrap: break-word; |
overflow-wrap: break-word; |
||||
} |
} |
||||
|
|
||||
|
#gravatar { |
||||
|
margin: 10px; |
||||
|
} |
||||
|
|
||||
|
#profile-photo { |
||||
|
margin-bottom: 10px; |
||||
|
} |
||||
|
|
||||
|
.custom-heading { |
||||
|
margin-bottom: 20px !important; |
||||
|
font-size: 28px !important; |
||||
|
} |
||||
|
|
||||
|
.company-jobtitle { |
||||
|
font-size: 16px !important; |
||||
|
font-weight: 300 !important; |
||||
|
margin-bottom: 20px; |
||||
|
} |
||||
|
|
||||
|
.username-website { |
||||
|
font-size: 16px !important; |
||||
|
font-weight: 400 !important; |
||||
|
margin-bottom: 20px; |
||||
|
} |
||||
|
|
||||
|
.custom-small { |
||||
|
display: block; |
||||
|
} |
||||
|
|||||
@ -0,0 +1,40 @@ |
|||||
|
import { AuthErrorEvent, AuthErrorFilter } from '../models'; |
||||
|
|
||||
|
export abstract class AbstractAuthErrorFilter<T, E> { |
||||
|
abstract get(id: string): T; |
||||
|
abstract add(filter: T): void; |
||||
|
abstract patch(item: Partial<T>): void; |
||||
|
abstract remove(id: string): void; |
||||
|
abstract run(event: E): boolean; |
||||
|
} |
||||
|
|
||||
|
export class AuthErrorFilterService< |
||||
|
T = AuthErrorFilter, |
||||
|
E = AuthErrorEvent, |
||||
|
> extends AbstractAuthErrorFilter<T, E> { |
||||
|
private warningMessage() { |
||||
|
console.error('You should add @abp/ng-oauth packages or create your own auth packages.'); |
||||
|
} |
||||
|
|
||||
|
get(id: string): T { |
||||
|
this.warningMessage(); |
||||
|
throw new Error('not implemented'); |
||||
|
} |
||||
|
|
||||
|
add(filter: T): void { |
||||
|
this.warningMessage(); |
||||
|
} |
||||
|
|
||||
|
patch(item: Partial<T>): void { |
||||
|
this.warningMessage(); |
||||
|
} |
||||
|
|
||||
|
remove(id: string): void { |
||||
|
this.warningMessage(); |
||||
|
} |
||||
|
|
||||
|
run(event: E): boolean { |
||||
|
this.warningMessage(); |
||||
|
throw new Error('not implemented'); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,54 @@ |
|||||
|
export type EventType = |
||||
|
| 'discovery_document_loaded' |
||||
|
| 'jwks_load_error' |
||||
|
| 'invalid_nonce_in_state' |
||||
|
| 'discovery_document_load_error' |
||||
|
| 'discovery_document_validation_error' |
||||
|
| 'user_profile_loaded' |
||||
|
| 'user_profile_load_error' |
||||
|
| 'token_received' |
||||
|
| 'token_error' |
||||
|
| 'code_error' |
||||
|
| 'token_refreshed' |
||||
|
| 'token_refresh_error' |
||||
|
| 'silent_refresh_error' |
||||
|
| 'silently_refreshed' |
||||
|
| 'silent_refresh_timeout' |
||||
|
| 'token_validation_error' |
||||
|
| 'token_expires' |
||||
|
| 'session_changed' |
||||
|
| 'session_error' |
||||
|
| 'session_terminated' |
||||
|
| 'session_unchanged' |
||||
|
| 'logout' |
||||
|
| 'popup_closed' |
||||
|
| 'popup_blocked' |
||||
|
| 'token_revoke_error'; |
||||
|
|
||||
|
export abstract class AuthEvent { |
||||
|
constructor(public readonly type: EventType) { |
||||
|
this.type = type; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export class AuthSuccessEvent extends AuthEvent { |
||||
|
constructor(public readonly type: EventType, public readonly info?: any) { |
||||
|
super(type); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export class AuthInfoEvent extends AuthEvent { |
||||
|
constructor(public readonly type: EventType, public readonly info?: any) { |
||||
|
super(type); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
export class AuthErrorEvent extends AuthEvent { |
||||
|
constructor( |
||||
|
public readonly type: EventType, |
||||
|
public readonly reason: object, |
||||
|
public readonly params?: object, |
||||
|
) { |
||||
|
super(type); |
||||
|
} |
||||
|
} |
||||
@ -1 +1,2 @@ |
|||||
export * from './oauth.service'; |
export * from './oauth.service'; |
||||
|
export * from './oauth-error-filter.service'; |
||||
|
|||||
@ -0,0 +1,45 @@ |
|||||
|
import { Injectable, signal } from '@angular/core'; |
||||
|
import { OAuthErrorEvent } from 'angular-oauth2-oidc'; |
||||
|
import { AbstractAuthErrorFilter, AuthErrorFilter } from '@abp/ng.core'; |
||||
|
|
||||
|
@Injectable({ providedIn: 'root' }) |
||||
|
export class OAuthErrorFilterService extends AbstractAuthErrorFilter< |
||||
|
AuthErrorFilter<OAuthErrorEvent>, |
||||
|
OAuthErrorEvent |
||||
|
> { |
||||
|
protected readonly _filters = signal<Array<AuthErrorFilter<OAuthErrorEvent>>>([]); |
||||
|
readonly filters = this._filters.asReadonly(); |
||||
|
|
||||
|
get(id: string): AuthErrorFilter<OAuthErrorEvent> { |
||||
|
return this._filters().find(({ id: _id }) => _id === id); |
||||
|
} |
||||
|
|
||||
|
add(filter: AuthErrorFilter<OAuthErrorEvent>): void { |
||||
|
this._filters.update(items => [...items, filter]); |
||||
|
} |
||||
|
|
||||
|
patch(item: Partial<AuthErrorFilter<OAuthErrorEvent>>): void { |
||||
|
const _item = this.filters().find(({ id }) => id === item.id); |
||||
|
if (!_item) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
Object.assign(_item, item); |
||||
|
} |
||||
|
|
||||
|
remove(id: string): void { |
||||
|
const item = this.filters().find(({ id: _id }) => _id === id); |
||||
|
if (!item) { |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
this._filters.update(items => items.filter(({ id: _id }) => _id !== id)); |
||||
|
} |
||||
|
|
||||
|
run(event: OAuthErrorEvent): boolean { |
||||
|
return this.filters() |
||||
|
.filter(({ executable }) => !!executable) |
||||
|
.map(({ execute }) => execute(event)) |
||||
|
.some(item => item); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,100 @@ |
|||||
|
import glob from "glob"; |
||||
|
import fse from "fs-extra"; |
||||
|
import {program} from "commander"; |
||||
|
|
||||
|
(function findPackageJsonFiles() { |
||||
|
setupCommander(); |
||||
|
const options = { |
||||
|
ignore: [ |
||||
|
"../../**/node_modules/**", |
||||
|
"../../**/dist/**", |
||||
|
"../../**/build/**", |
||||
|
"../../**/scripts/**", |
||||
|
"../../**/wwwroot/**" |
||||
|
] |
||||
|
}; |
||||
|
|
||||
|
const workingDir = "../../"; |
||||
|
glob(`${workingDir}**/package.json`, options, (err, files) => { |
||||
|
if (err) throw err; |
||||
|
|
||||
|
const {packageName,targetVersion}= program.opts(); |
||||
|
|
||||
|
for (const file of files) { |
||||
|
readPackageJsonFile(file, packageName, targetVersion); |
||||
|
} |
||||
|
}); |
||||
|
})(); |
||||
|
|
||||
|
function readPackageJsonFile(path, key, newVersion) { |
||||
|
const replace = (block, key, newVersion) => { |
||||
|
const founded = Object.keys(block).filter(x => x === key); |
||||
|
if (founded.length > 0) { |
||||
|
let value = block[key]; |
||||
|
value = value.replace(semverRegex, newVersion); |
||||
|
return [true, { |
||||
|
...block, |
||||
|
[key]:value |
||||
|
}]; |
||||
|
} |
||||
|
return [false, block]; |
||||
|
}; |
||||
|
fse.readJson(path, (err, packageObj) => { |
||||
|
if (err) throw err; |
||||
|
|
||||
|
const { dependencies, peerDependencies, devDependencies } = packageObj; |
||||
|
const results = []; |
||||
|
|
||||
|
let result = { ...packageObj }; |
||||
|
if (dependencies) { |
||||
|
const [founded, d] = replace(dependencies, key, newVersion); |
||||
|
results.push(founded); |
||||
|
result = { |
||||
|
...result, dependencies: d |
||||
|
}; |
||||
|
} |
||||
|
if (peerDependencies) { |
||||
|
const [founded, p] = replace(peerDependencies, key, newVersion); |
||||
|
results.push(founded); |
||||
|
result = { |
||||
|
...result, peerDependencies: p |
||||
|
}; |
||||
|
} |
||||
|
if (devDependencies) { |
||||
|
const [founded, d] = replace(devDependencies, key, newVersion); |
||||
|
results.push(founded); |
||||
|
result = { |
||||
|
...result, devDependencies: d |
||||
|
}; |
||||
|
} |
||||
|
const anyChanges = !results.some(x => x); |
||||
|
if (anyChanges) { |
||||
|
return; |
||||
|
} |
||||
|
console.log("changed", path); |
||||
|
writeFile(path, result); |
||||
|
} |
||||
|
) |
||||
|
; |
||||
|
} |
||||
|
export const semverRegex = |
||||
|
/\d+\.\d+\.\d+(?:-[a-zA-Z0-9]+(?:\.[a-zA-Z0-9-]+)*)?(?:\+[a-zA-Z0-9]+(?:\.[a-zA-Z0-9-]+)*)?$/; |
||||
|
|
||||
|
function writeFile(path, result) { |
||||
|
return fse.writeJson(path, result, { spaces: 2 }); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
function setupCommander() { |
||||
|
program |
||||
|
.option( |
||||
|
"-n, --packageName <packageName>", |
||||
|
"Package name" |
||||
|
) |
||||
|
.option( |
||||
|
"-v, --targetVersion <targetVersion>", |
||||
|
"Version number of the package" |
||||
|
); |
||||
|
|
||||
|
program.parse(process.argv); |
||||
|
} |
||||
Loading…
Reference in new issue