Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add link to eIAM MyAccount #1631

Merged
merged 1 commit into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ WORKDIR /usr/src/app
# --build-arg MAPTILER_STYLE_KEY=<maptiler style key> \
# --build-arg ADFS_ID=<adfs client id> \
# --build-arg ADFS_ISSUER=<adfs issuer> \
# --build-arg ADFS_PROFILE_URL=<adfs profile url> \
# --build-arg NEXTAUTH_SECRET=<nextauth secret> \
# --build-arg NEXTAUTH_URL=<nextauth url>

Expand All @@ -19,6 +20,7 @@ ARG VECTOR_TILE_URL
ARG MAPTILER_STYLE_KEY
ARG ADFS_ID
ARG ADFS_ISSUER
ARG ADFS_PROFILE_URL
ARG NEXTAUTH_SECRET
ARG NEXTAUTH_URL

Expand All @@ -38,6 +40,7 @@ ENV NEXT_PUBLIC_BASE_VECTOR_TILE_URL=$VECTOR_TILE_URL
ENV NEXT_PUBLIC_MAPTILER_STYLE_KEY=$MAPTILER_STYLE_KEY
ENV ADFS_ID=$ADFS_ID
ENV ADFS_ISSUER=$ADFS_ISSUER
ENV ADFS_PROFILE_URL=$ADFS_PROFILE_URL
ENV NEXTAUTH_SECRET=$NEXTAUTH_SECRET
ENV NEXTAUTH_URL=$NEXTAUTH_URL

Expand Down
1 change: 1 addition & 0 deletions app/.env.development
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ WHITELISTED_DATA_SOURCES=["Prod", "Int", "Test"]
SENTRY_IGNORE_API_RESOLUTION_ERROR=1
NEXT_PUBLIC_VECTOR_TILE_URL=https://world.vectortiles.geo.admin.ch
NEXT_PUBLIC_MAPTILER_STYLE_KEY=123
ADFS_PROFILE_URL=https://www.myaccount-r.eiam.admin.ch/
3 changes: 3 additions & 0 deletions app/domain/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ export const GRAPHQL_ENDPOINT =
export const GA_TRACKING_ID =
clientEnv?.GA_TRACKING_ID ?? process.env.GA_TRACKING_ID;

export const ADFS_PROFILE_URL =
clientEnv?.ADFS_PROFILE_URL ?? process.env.ADFS_PROFILE_URL;

/**
* Server-side-only **RUNTIME** variables (not exposed through window)
*/
Expand Down
25 changes: 17 additions & 8 deletions app/login/components/profile-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import clsx from "clsx";
import { signOut } from "next-auth/react";
import NextLink from "next/link";

import { ADFS_PROFILE_URL } from "@/domain/env";
import { useRootStyles } from "@/login/utils";

const useStyles = makeStyles<Theme>((theme) => ({
Expand All @@ -18,29 +19,37 @@ const useStyles = makeStyles<Theme>((theme) => ({
alignItems: "center",
justifyContent: "space-between",
},
browseButton: {
button: {
width: "fit-content",
},
}));

type ProfileHeaderProps = {
user: User;
};

export const ProfileHeader = (props: ProfileHeaderProps) => {
export const ProfileHeader = (props: { user: User }) => {
const { user } = props;
const rootClasses = useRootStyles();
const classes = useStyles();

return (
<Box className={clsx(rootClasses.section, classes.section)}>
<Box className={rootClasses.sectionContent}>
<Box className={classes.topRow}>
<Typography variant="h1">{user.name}</Typography>
<BrowseButton />
</Box>
{ADFS_PROFILE_URL && (
<Button
className={classes.button}
component="a"
href={`${ADFS_PROFILE_URL}?returnUrl=${encodeURIComponent(window.location.href)}`}
variant="text"
color="primary"
size="small"
sx={{ marginRight: 2 }}
>
eIAM MyAccount
</Button>
)}
<Button
className={classes.browseButton}
className={classes.button}
variant="text"
color="primary"
size="small"
Expand Down
1 change: 1 addition & 0 deletions app/pages/api/client-env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default async function clientEnvApi(
SQL_ENDPOINT: process.env.SQL_ENDPOINT,
PUBLIC_URL: process.env.PUBLIC_URL,
GRAPHQL_ENDPOINT: process.env.GRAPHQL_ENDPOINT,
ADFS_PROFILE_URL: process.env.ADFS_PROFILE_URL,
})}`;

if (result) {
Expand Down
1 change: 1 addition & 0 deletions scripts/docker-build-push.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ docker build \
--build-arg VECTOR_TILE_URL=$VECTOR_TILE_URL \
--build-arg ADFS_ID=$ADFS_ID \
--build-arg ADFS_ISSUER=$ADFS_ISSUER \
--build-arg ADFS_PROFILE_URL=$ADFS_PROFILE_URL \
--build-arg NEXTAUTH_SECRET=$NEXTAUTH_SECRET \
--build-arg NEXTAUTH_URL=$NEXTAUTH_URL \
$(echo $DOCKER_IMAGE_TAGS | tr ' ' '\n' | xargs -n 1 -I {} echo "-t {}" ) .
Expand Down
Loading