Updated packages and Dockerfile
This commit is contained in:
32
public/js-source/src/utils/userinfo.ts
Normal file
32
public/js-source/src/utils/userinfo.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
export interface UserInfo {
|
||||
sub: string;
|
||||
name?: string;
|
||||
given_name?: string;
|
||||
family_name?: string;
|
||||
middle_name?: string;
|
||||
nickname?: string;
|
||||
preferred_username?: string;
|
||||
profile?: string;
|
||||
picture?: string;
|
||||
website?: string;
|
||||
email?: string;
|
||||
email_verified?: boolean;
|
||||
gender?: string;
|
||||
birthdate?: string;
|
||||
zoneinfo?: string;
|
||||
locale?: string;
|
||||
phone_number?: string;
|
||||
updated_at?: number;
|
||||
address?: {
|
||||
formatted?: string;
|
||||
street_address?: string;
|
||||
locality?: string;
|
||||
region?: string;
|
||||
postal_code?: string;
|
||||
country?: string;
|
||||
|
||||
[key: string]: unknown;
|
||||
};
|
||||
groups?: string[];
|
||||
[key: string]: unknown;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
import {WaitForSync} from './resolvable';
|
||||
import {UserInfo} from './userinfo';
|
||||
|
||||
export interface ClientConfig {
|
||||
EXTERNAL_BASE_URL: string
|
||||
@@ -20,19 +21,8 @@ export function resetConfig(): void {
|
||||
return configWaiter.reset();
|
||||
}
|
||||
|
||||
export async function getUserInfo(): Promise<Partial<UserInfo>|undefined> {
|
||||
export async function getUserInfo(): Promise<UserInfo|undefined> {
|
||||
const config = await getConfig();
|
||||
const res = await fetch(config.EXTERNAL_BASE_URL + '/api/user');
|
||||
return res.json();
|
||||
}
|
||||
|
||||
export type UserInfo = {
|
||||
email: string,
|
||||
email_verified: boolean,
|
||||
family_name: string,
|
||||
given_name: string,
|
||||
groups: string[],
|
||||
name: string,
|
||||
preferred_username: string,
|
||||
sub: string,
|
||||
};
|
||||
|
||||
@@ -4,7 +4,8 @@ import {expect} from 'chai';
|
||||
// @ts-ignore
|
||||
import * as fetchMock from 'fetch-mock';
|
||||
import {getUserName} from '../src/SomeModule';
|
||||
import {setConfig, UserInfo} from '../src/utils/utils';
|
||||
import {setConfig} from '../src/utils/utils';
|
||||
import {UserInfo} from '../src/utils/userinfo';
|
||||
|
||||
describe('frontend:SomeModule', () => {
|
||||
const CONFIG = {EXTERNAL_BASE_URL: 'http://demo.url'};
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
/* eslint-disable promise/catch-or-return,promise/no-callback-in-promise */
|
||||
import {setConfig, getConfig, resetConfig, getUserInfo, UserInfo} from '../src/utils/utils';
|
||||
import {setConfig, getConfig, resetConfig, getUserInfo} from '../src/utils/utils';
|
||||
import {Resolvable, WaitForSync} from '../src/utils/resolvable';
|
||||
import {describe, it} from 'mocha';
|
||||
import {expect} from 'chai';
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
import * as fetchMock from 'fetch-mock';
|
||||
import {UserInfo} from '../src/utils/userinfo';
|
||||
|
||||
describe('frontend:utils - setConfig/getConfig', () => {
|
||||
const CONFIG = {EXTERNAL_BASE_URL: 'http://demo.url'};
|
||||
|
||||
Reference in New Issue
Block a user