Use federation.universalLogin in Welcome

This commit is contained in:
Marquis Kurt 2019-05-08 09:14:46 -04:00
parent 4987040a39
commit ced1dfc3b5
4 changed files with 19 additions and 37 deletions

View File

@ -1,22 +0,0 @@
import {License} from '../types/Config';
export interface Config {
version: string;
location: string;
branding?: {
name?: string;
logo?: string;
background?: string;
};
developer?: string;
federated?: string;
registration?: {
defaultInstance?: string;
};
admin?: {
name?: string;
account?: string;
};
license: License;
respository?: string;
}

View File

@ -8,6 +8,7 @@ import {parseUrl} from 'query-string';
import { getConfig } from '../utilities/settings';
import axios from 'axios';
import {withSnackbar, withSnackbarProps} from 'notistack';
import { Config } from '../types/Config';
interface IWelcomeProps extends withSnackbarProps {
classes: any;
@ -59,20 +60,23 @@ class WelcomePage extends Component<IWelcomeProps, IWelcomeState> {
}
getConfig().then((result: any) => {
if (result.location === "dynamic") {
console.warn("Recirect URI is set to dyanmic, which may affect how sign-in works for some users. Careful!");
if (result !== undefined) {
let config: Config = result;
if (config.location === "dynamic") {
console.warn("Recirect URI is set to dyanmic, which may affect how sign-in works for some users. Careful!");
}
this.setState({
logoUrl: config.branding? result.branding.logo: "logo.png",
backgroundUrl: config.branding? result.branding.background: "background.png",
brandName: config.branding? result.branding.name: "Hyperspace",
registerBase: config.registration? result.registration.defaultInstance: "",
federates: config.federation.universalLogin,
license: config.license.url,
repo: config.repository,
defaultRedirectAddress: config.location != "dynamic"? config.location: `https://${window.location.host}`,
version: config.version
});
}
this.setState({
logoUrl: result.branding? result.branding.logo: "logo.png",
backgroundUrl: result.branding? result.branding.background: "background.png",
brandName: result.branding? result.branding.name: "Hyperspace",
registerBase: result.registration? result.registration.defaultInstance: "",
federates: result.federated? result.federated === "true": true,
license: result.license.url,
repo: result.repository,
defaultRedirectAddress: result.location != "dynamic"? result.location: `https://${window.location.host}`,
version: result.version
});
}).catch(() => {
console.error('config.json is missing. If you want to customize Hyperspace, please include config.json');
})

View File

@ -16,7 +16,7 @@ export type Config = {
account?: string;
};
license: License;
respository?: string;
repository?: string;
}
export type License = {

View File

@ -116,7 +116,7 @@ export function createUserDefaults() {
* Gets the configuration data from `config.json`
* @returns The Promise data from getting the config.
*/
export async function getConfig() {
export async function getConfig(): Promise<Config | undefined> {
try {
const resp = await axios.get('config.json');
let config: Config = resp.data;