update .gitignore, add example environment file, and modify consent handling in components

This commit is contained in:
2025-08-10 10:40:42 +03:00
parent e43a8b0865
commit d09664ad57
10 changed files with 50 additions and 59 deletions

View File

@ -27,17 +27,7 @@ const ConsentButton: FC = () => {
};
const requestConsent = () => {
// if (!auth.loginChallenge || auth.scope.length === 0) return;
// new AuthService()
// .requestConsent(auth.loginChallenge)
// .then(response => response.data)
// .then(({ clientName }) => {
// setClientName(clientName);
// })
// .catch(error => {
// console.error(error);
// notifications.error({ message: error.toString() });
// });
};
useEffect(() => {
@ -46,13 +36,21 @@ const ConsentButton: FC = () => {
}, []);
const confirmAccess = () => {
const phoneNumber = auth.phoneNumber;
if (!phoneNumber) {
console.error("Phone number is not set");
return;
}
const consentChallenge = searchParams.get("consent_challenge");
if (!consentChallenge) {
console.error("Consent challenge is missing in the URL");
return;
}
Auth.postAuthConsentAccept({
body: { consent_challenge: consentChallenge },
body: {
consent_challenge: consentChallenge,
phone_number: phoneNumber,
},
})
.then(response => response.data)
.then(response => {
@ -69,17 +67,7 @@ const ConsentButton: FC = () => {
console.error("Redirect URL is missing in the response");
}
});
// if (!auth.loginChallenge) return;
// new AuthService()
// .approveConsent(auth.loginChallenge)
// .then(response => response.data)
// .then(({ redirectUrl }) => {
// window.location.href = redirectUrl;
// })
// .catch(error => {
// console.error(error);
// notifications.error({ message: error.toString() });
// });
};
return (

View File

@ -9,8 +9,12 @@ import SCOPES from "@/constants/scopes";
import { Scopes } from "@/enums/Scopes";
import { setTargetService } from "@/lib/store/features/targetService/targetServiceSlice";
import { useAppDispatch } from "@/lib/store/store";
import ServiceData from "@/types/ServiceData";
type ServiceData = {
id: number;
code: Scopes;
name: string;
};
const ServicesList = () => {
const dispatch = useAppDispatch();
const services = useMemo(
@ -56,7 +60,9 @@ const ServicesList = () => {
<Stack
className={styles.container}
gap={"lg"}>
{services.map((service, i) => getServiceButton(service, i))}
{services.map((service, i) =>
getServiceButton(service as unknown as ServiceData, i)
)}
<TitleWithLines title="Скоро будет" />
{getServiceInDevelopment("Analytics")}
</Stack>

View File

@ -27,13 +27,13 @@ const VerifyPhoneForm: FC = () => {
const authState = useSelector((state: RootState) => state.auth);
const handleSubmit = (values: VerifyNumberForm) => {
if (!authState.phoneNumber || !authState.loginChallenge) return;
console.log(authState.phoneNumber.replace(/ /g, ""));
Auth.postAuthOtpVerify({
body: {
phone_number: authState.phoneNumber.replace(" ", ""),
phone_number: authState.phoneNumber,
login_challenge: authState.loginChallenge,
otp: values.code,
},