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: Redirection of user certificates to new url #777

Closed
wants to merge 2 commits into from
Closed
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 .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ PUBLIC_CRYPTO_PRIVATE_KEY=

PUBLIC_SHOW_NAME_AS_LOGO= # Please provide true if you want to give platform name with logo

PUBLIC_REDIRECT_FROM_URL= # Please provide the URL that will be redirected from
PUBLIC_REDIRECTION_TARGET_URL= # Please provide the URL that will be redirected to

PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID= # Please sepcify your client id
PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET= # Please specify your client secrete

Expand Down
27 changes: 7 additions & 20 deletions src/components/UserCertificate.astro
Original file line number Diff line number Diff line change
@@ -1,21 +1,8 @@
---
import { apiRoutes } from '../config/apiRoutes'
import API from '../config/ssrApiConfig';
<script>
import { envConfig } from "../config/envConfig";

const { credId } = Astro.props;

const fetchApi = await API({
url: `${apiRoutes.users.userCredentials}/${credId}`,
token: '',
method: 'GET',
});
const imageUrl = fetchApi?.imageUrl;
---
<head>
<meta property="og:title" content="World Memory Championship Certificate" />
<meta property="og:description" content="World Memory Championship Certificate for participants, winners, arbitors, and record holders." />
<meta property="og:image" content={imageUrl} />
</head>
<div>
<img src={imageUrl} alt="World Memory Championship Certificate" />
</div>
if (window.location.origin === `${envConfig.PUBLIC_REDIRECT_FROM_URL}`) {
const credId = new URL(window.location.href).pathname.split('/').pop();
window.location.href = `${envConfig.PUBLIC_REDIRECTION_TARGET_URL}/certificates/${credId}`;
}
</script>
3 changes: 1 addition & 2 deletions src/config/apiRoutes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export const apiRoutes = {
fetchUsers: '/users',
update: '/users',
recentActivity: '/users/activity',
platformSettings: '/users/platform-settings',
userCredentials:'/users/user-credentials'
platformSettings: '/users/platform-settings'
},
organizations: {
root: '/orgs',
Expand Down
6 changes: 4 additions & 2 deletions src/config/envConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ if (import.meta.env) {
}
}

const { PUBLIC_BASE_URL, PUBLIC_ECOSYSTEM_FRONT_END_URL, PUBLIC_POLYGON_TESTNET_URL, PUBLIC_POLYGON_MAINNET_URL, PUBLIC_CRYPTO_PRIVATE_KEY,PUBLIC_SHOW_NAME_AS_LOGO, PUBLIC_PLATFORM_NAME, PUBLIC_PLATFORM_LOGO, PUBLIC_POWERED_BY, PUBLIC_PLATFORM_WEB_URL, PUBLIC_POWERED_BY_URL, PUBLIC_PLATFORM_DOCS_URL, PUBLIC_PLATFORM_GIT, PUBLIC_PLATFORM_SUPPORT_EMAIL, PUBLIC_PLATFORM_TWITTER_URL, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, PUBLIC_PLATFORM_SUPPORT_INVITE, PUBLIC_PLATFORM_DISCORD_URL, PUBLIC_ALLOW_DOMAIN, PUBLIC_ECOSYSTEM_BASE_URL }: any = envVariables;
const { PUBLIC_BASE_URL, PUBLIC_ECOSYSTEM_FRONT_END_URL, PUBLIC_POLYGON_TESTNET_URL, PUBLIC_POLYGON_MAINNET_URL, PUBLIC_CRYPTO_PRIVATE_KEY,PUBLIC_SHOW_NAME_AS_LOGO, PUBLIC_PLATFORM_NAME, PUBLIC_PLATFORM_LOGO, PUBLIC_POWERED_BY, PUBLIC_PLATFORM_WEB_URL, PUBLIC_POWERED_BY_URL, PUBLIC_PLATFORM_DOCS_URL, PUBLIC_PLATFORM_GIT, PUBLIC_PLATFORM_SUPPORT_EMAIL, PUBLIC_PLATFORM_TWITTER_URL, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_ID, PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET, PUBLIC_PLATFORM_SUPPORT_INVITE, PUBLIC_PLATFORM_DISCORD_URL, PUBLIC_ALLOW_DOMAIN, PUBLIC_ECOSYSTEM_BASE_URL, PUBLIC_REDIRECT_FROM_URL, PUBLIC_REDIRECTION_TARGET_URL }: any = envVariables;

export const envConfig = {
PUBLIC_BASE_URL:
Expand Down Expand Up @@ -73,5 +73,7 @@ export const envConfig = {
PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET ||
import.meta.env.PUBLIC_KEYCLOAK_MANAGEMENT_CLIENT_SECRET,
},
PUBLIC_ALLOW_DOMAIN: PUBLIC_ALLOW_DOMAIN || import.meta.env.PUBLIC_ALLOW_DOMAIN
PUBLIC_ALLOW_DOMAIN: PUBLIC_ALLOW_DOMAIN || import.meta.env.PUBLIC_ALLOW_DOMAIN,
PUBLIC_REDIRECT_FROM_URL: PUBLIC_REDIRECT_FROM_URL || import.meta.env.PUBLIC_REDIRECT_FROM_URL,
PUBLIC_REDIRECTION_TARGET_URL: PUBLIC_REDIRECTION_TARGET_URL || import.meta.env.PUBLIC_REDIRECTION_TARGET_URL
}
Loading