Skip to content
Snippets Groups Projects
Commit a3d12cad authored by Piotr Gawron's avatar Piotr Gawron
Browse files

link for orcid oauth

parent 3c63fb1a
No related branches found
No related tags found
3 merge requests!223reset the pin numbers before search results are fetch (so the results will be...,!204Resolve "[MIN-320] opening project without permission",!203Resolve "Login via orcid"
Pipeline #91354 passed
window.config = {
BASE_API_URL: 'https://lux1.atcomp.pl/minerva/api',
BASE_NEW_API_URL: 'https://lux1.atcomp.pl/minerva/new_api/',
BASE_MAP_IMAGES_URL: 'https://lux1.atcomp.pl/',
BASE_API_URL: 'http://localhost:8080/minerva/api',
BASE_NEW_API_URL: 'http://localhost:8080/minerva/new_api/',
BASE_MAP_IMAGES_URL: 'http://localhost:8080/',
DEFAULT_PROJECT_ID: 'pdmap_appu_test',
ADMIN_PANEL_URL: 'https://lux1.atcomp.pl/minerva/admin.xhtml',
ADMIN_PANEL_URL: 'http://localhost:8080/minerva/admin.xhtml',
};
src/assets/images/orcid.png

2.08 KiB

......@@ -7,6 +7,7 @@ import { MINUS_ONE, ZERO } from '@/constants/common';
import { Button } from '@/shared/Button';
import { adminEmailValSelector } from '@/redux/configuration/configuration.selectors';
import { projectsSelector } from '@/redux/projects/projects.selectors';
import { getOAuth } from '@/redux/oauth/oauth.thunks';
export const AccessDeniedModal: React.FC = () => {
const dispatch = useAppDispatch();
......@@ -28,6 +29,7 @@ export const AccessDeniedModal: React.FC = () => {
const handleLogin = async (e: React.FormEvent<HTMLButtonElement>): Promise<void> => {
e.preventDefault();
dispatch(getOAuth());
dispatch(openLoginModal());
};
......
......@@ -7,6 +7,10 @@ import { Button } from '@/shared/Button';
import { Input } from '@/shared/Input';
import Link from 'next/link';
import React from 'react';
import { BASE_API_URL } from '@/constants';
import { orcidEndpointSelector } from '@/redux/oauth/oauth.selectors';
import Image from 'next/image';
import orcidLogoImg from '@/assets/images/orcid.png';
export const LoginModal: React.FC = () => {
const dispatch = useAppDispatch();
......@@ -14,11 +18,19 @@ export const LoginModal: React.FC = () => {
const isPending = loadingUser === 'pending';
const [credentials, setCredentials] = React.useState({ login: '', password: '' });
const orcidEndpoint = useAppSelector(orcidEndpointSelector);
const isOrcidAvailable = orcidEndpoint !== undefined;
const handleChange = (e: React.ChangeEvent<HTMLInputElement>): void => {
const { name, value } = e.target;
setCredentials(prevCredentials => ({ ...prevCredentials, [name]: value }));
};
const handleLoginViaOrcid = (): void => {
window.location.href = `${BASE_API_URL}/..${orcidEndpoint}`;
};
const handleSubmit = async (e: React.FormEvent<HTMLFormElement>): Promise<void> => {
e.preventDefault();
await dispatch(login(credentials));
......@@ -57,6 +69,16 @@ export const LoginModal: React.FC = () => {
Forgot password?
</Link>
</div>
{isOrcidAvailable && (
<Button
variantStyles="quiet"
className="mb-1 w-full justify-center text-base font-medium"
onClick={handleLoginViaOrcid}
>
<Image src={orcidLogoImg} alt="orcid logo" height={32} width={32} className="mr-1.5" />
Sign in with Orcid
</Button>
)}
<Button
type="submit"
className="w-full justify-center text-base font-medium"
......
......@@ -8,6 +8,7 @@ import { apiPath } from '@/redux/apiPath';
import { HttpStatusCode } from 'axios';
import mockRouter from 'next-router-mock';
import { projectFixture } from '@/models/fixtures/projectFixture';
import { oauthFixture } from '@/models/fixtures/oauthFixture';
import { User } from './User.component';
const mockedAxiosClient = mockNetworkResponse();
......@@ -131,6 +132,8 @@ describe('AuthenticatedUser component', () => {
});
it('should display login modal if switch account is pressed', async () => {
mockedAxiosClient.onGet(apiPath.getOauthProviders()).reply(HttpStatusCode.Ok, oauthFixture);
const { store } = renderComponent({
user: {
...USER_INITIAL_STATE_MOCK,
......
......@@ -8,6 +8,7 @@ import { useRouter } from 'next/router';
import { USER_ROLE } from '@/constants/user';
import { useMemo } from 'react';
import { CURRENT_PROJECT_ADMIN_PANEL_URL } from '@/constants';
import { getOAuth } from '@/redux/oauth/oauth.thunks';
import { ADMIN_CURATOR_ACTIONS, BASE_ACTIONS } from '../User.constants';
type UseUserActionsReturnType = {
......@@ -33,6 +34,7 @@ export const useUserActions = (): UseUserActionsReturnType => {
}, [userRole]);
const openModalLogin = (): void => {
dispatch(getOAuth());
dispatch(openLoginModal());
};
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment