Skip to content

Commit

Permalink
update signup ui env (mosip#41)
Browse files Browse the repository at this point in the history
Co-authored-by: Sreang Rathanak <[email protected]>
Signed-off-by: Sreang Rathanak <[email protected]>
  • Loading branch information
rathanak-0080 and Sreang Rathanak committed Jan 15, 2024
1 parent 274e168 commit 64270b4
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ mosip.signup.ui.config.key-values={\
'fullname.pattern': '${mosip.signup.fullname.pattern}', \
'status.request.delay': ${mosip.signup.status.request.delay}, \
'status.request.limit': ${mosip.signup.status.request.limit}, \
'popup.timeout': 10 \
'popup.timeout': 10, \
'signin.redirect-url': 'https://esignet.camdgc-dev.mosip.net/authorize' \
}

## ----------------------------- SMS-message -----------------------------------------------------------------------------
mosip.signup.sms-notification-template.send-otp.khm=ប្រើ {challenge} ដើម្បីផ្ទៀងផ្ទាត់គណនី KhID របស់អ្នក។
mosip.signup.sms-notification-template.send-otp.eng=Use {challenge} to verify your KhID account.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public void getSignupSettings_thenPass () throws Exception {
.andExpect(jsonPath("$['response']['configs']['fullname.pattern']").value(".*"))
.andExpect(jsonPath("$['response']['configs']['status.request.delay']").value(20))
.andExpect(jsonPath("$['response']['configs']['status.request.limit']").value(10))
.andExpect(jsonPath("$['response']['configs']['signin.redirect-url']").value("https://esignet.camdgc-dev.mosip.net/authorize"))
.andExpect(jsonPath("$.errors").isEmpty());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ mosip.signup.ui.config.key-values={\
'resend.delay': '${mosip.signup.challenge.resend-delay}', \
'fullname.pattern': '${mosip.signup.fullname.pattern}', \
'status.request.delay': '${mosip.signup.status.request.delay}', \
'status.request.limit': '${mosip.signup.status.request.limit}' \
'status.request.limit': '${mosip.signup.status.request.limit}', \
'signin.redirect-url': 'https://esignet.camdgc-dev.mosip.net/authorize' \
}
## ----------------------------- SMS-message -----------------------------------------------------------------------------
mosip.signup.otp-registration.sms.khm=ប្រើ XXXXXX ដើម្បីផ្ទៀងផ្ទាត់គណនី KhID របស់អ្នក។
Expand Down
2 changes: 0 additions & 2 deletions signup-ui/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
REACT_APP_API_BASE_URL="http://localhost:8088/v1/signup"
REACT_APP_REDIRECT_SIGN_IN_URL="https://esignet.camdgc-dev.mosip.net/authorize"
REACT_APP_REDIRECT_SIGN_UP_URL="http://localhost:3000/signup"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { ReactComponent as FailedIconSvg } from "~assets/svg/failed-icon.svg";
import { ReactComponent as SuccessIconSvg } from "~assets/svg/success-icon.svg";
import { Button } from "~components/ui/button";
import { Step, StepContent } from "~components/ui/step";
import { useSettings } from "~pages/SignUpPage/queries";
import { getSignInRedirectURL } from "~utils/link";

interface AccountRegistrationStatusLayoutProps {
Expand All @@ -17,11 +18,12 @@ export const AccountRegistrationStatusLayout = ({
message,
}: AccountRegistrationStatusLayoutProps) => {
const { t } = useTranslation();
const { data: settings } = useSettings();
const { hash: fromSignInHash } = useLocation();

const handleAction = (e: any) => {
e.preventDefault();
window.location.href = getSignInRedirectURL(fromSignInHash);
window.location.href = getSignInRedirectURL(settings?.response.configs["signin.redirect-url"], fromSignInHash);
};

return (
Expand Down
3 changes: 1 addition & 2 deletions signup-ui/src/pages/SignUpPage/Phone/Phone.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ interface PhoneProps {
}
export const Phone = ({ settings, methods }: PhoneProps) => {
const { i18n, t } = useTranslation();

const { setStep, setCriticalError } = useSignUpStore(
useCallback(
(state) => ({
Expand Down Expand Up @@ -137,7 +136,7 @@ export const Phone = ({ settings, methods }: PhoneProps) => {
<StepTitle className="relative flex w-full items-center justify-center gap-x-4 text-base font-semibold">
{!!fromSignInHash && (
<a
href={getSignInRedirectURL(fromSignInHash)}
href={getSignInRedirectURL(settings?.response.configs["signin.redirect-url"], fromSignInHash)}
className="absolute left-0 ml-6 cursor-pointer"
>
<Icons.back />
Expand Down
4 changes: 3 additions & 1 deletion signup-ui/src/pages/SignUpPage/PhoneStatus/PhoneStatus.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ import { VerifyChallengeResponseDto } from "~typings/types";

import { SignUpForm } from "../SignUpPage";
import { setStepSelector, SignUpStep, useSignUpStore } from "../useSignUpStore";
import { useSettings } from "../queries";

interface PhoneStatusProps {
methods: UseFormReturn<SignUpForm, any, undefined>;
}

export const PhoneStatus = ({ methods }: PhoneStatusProps) => {
const { t } = useTranslation();
const { data: settings } = useSettings();

const { setStep } = useSignUpStore(
useCallback((state) => ({ setStep: setStepSelector(state) }), [])
Expand All @@ -42,7 +44,7 @@ export const PhoneStatus = ({ methods }: PhoneStatusProps) => {

const handleChallengeVerificationErrorRedirect = (e: any) => {
e.preventDefault();
window.location.href = getSignInRedirectURL(fromSignInHash);
window.location.href = getSignInRedirectURL(settings?.response.configs["signin.redirect-url"], fromSignInHash);
};

const [challengeVerification] = useMutationState<VerifyChallengeResponseDto>({
Expand Down
4 changes: 3 additions & 1 deletion signup-ui/src/pages/SignUpPage/SignUpPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@ import {
} from "~components/ui/alert-dialog";
import { getSignInRedirectURL } from "~utils/link";

import { useSettings } from "./queries";
import { criticalErrorSelector, useSignUpStore } from "./useSignUpStore";

export const SignUpPopover = () => {
const { t } = useTranslation();
const { data: settings } = useSettings();

const { criticalError } = useSignUpStore(
useCallback(
Expand All @@ -31,7 +33,7 @@ export const SignUpPopover = () => {

const handleAction = (e: any) => {
e.preventDefault();
window.location.href = getSignInRedirectURL(fromSignInHash);
window.location.href = getSignInRedirectURL(settings?.response.configs["signin.redirect-url"], fromSignInHash);
};

return (
Expand Down
5 changes: 4 additions & 1 deletion signup-ui/src/services/api.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { NavigateFunction } from "react-router-dom";

import { SOMETHING_WENT_WRONG } from "~constants/routes";

export const API_BASE_URL = process.env.REACT_APP_API_BASE_URL ?? "/api/";
const API_BASE_URL =
process.env.NODE_ENV === "development"
? process.env.REACT_APP_API_BASE_URL
: window.origin + process.env.REACT_APP_API_BASE_URL;

export class HttpError extends Error {
code: number;
Expand Down
1 change: 1 addition & 0 deletions signup-ui/src/typings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ interface SettingsConfig {
"status.request.limit": number;
"status.request.delay": number;
"popup.timeout": number;
"signin.redirect-url": string;
}

export interface Settings {
Expand Down
6 changes: 3 additions & 3 deletions signup-ui/src/utils/link.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Buffer } from "buffer";

export const getSignInRedirectURL = (hash: string): string => {
export const getSignInRedirectURL = (redirectUrl: string | undefined, hash: string): string => {
if (!!hash) {
const signInQueryParams = Buffer.from(hash ?? "", "base64")?.toString();
return process.env.REACT_APP_REDIRECT_SIGN_IN_URL + "?" + signInQueryParams;
return redirectUrl + "?" + signInQueryParams;
}

return process.env.REACT_APP_REDIRECT_SIGN_UP_URL || "/";
return "/";
};

0 comments on commit 64270b4

Please sign in to comment.