🚚(frontend) move auth to its own feature
We will move auth to its own feature to make it easier to manage and to make it more modular.
This commit is contained in:
@@ -3,10 +3,10 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|||||||
import { useEffect } from 'react';
|
import { useEffect } from 'react';
|
||||||
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { Auth } from '@/features/auth';
|
||||||
import '@/i18n/initI18n';
|
import '@/i18n/initI18n';
|
||||||
import { useResponsiveStore } from '@/stores/';
|
import { useResponsiveStore } from '@/stores/';
|
||||||
|
|
||||||
import { Auth } from './auth/';
|
|
||||||
import { ConfigProvider } from './config/';
|
import { ConfigProvider } from './config/';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
export * from './api/types';
|
|
||||||
export * from './Auth';
|
|
||||||
export * from './ButtonLogin';
|
|
||||||
export * from './useAuthStore';
|
|
||||||
@@ -1,3 +1,2 @@
|
|||||||
export * from './AppProvider';
|
export * from './AppProvider';
|
||||||
export * from './auth';
|
|
||||||
export * from './config';
|
export * from './config';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { PropsWithChildren, useEffect, useState } from 'react';
|
|||||||
|
|
||||||
import { Box } from '@/components';
|
import { Box } from '@/components';
|
||||||
|
|
||||||
import { useAuthStore } from './useAuthStore';
|
import { useAuthStore } from '../stores/useAuthStore';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: Remove this restriction when we will have a homepage design for non-authenticated users.
|
* TODO: Remove this restriction when we will have a homepage design for non-authenticated users.
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Button } from '@openfun/cunningham-react';
|
import { Button } from '@openfun/cunningham-react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
import { useAuthStore } from '@/core/auth';
|
import { useAuthStore } from '@/features/auth';
|
||||||
|
|
||||||
export const ButtonLogin = () => {
|
export const ButtonLogin = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
export * from './Auth';
|
||||||
|
export * from './ButtonLogin';
|
||||||
3
src/frontend/apps/impress/src/features/auth/index.ts
Normal file
3
src/frontend/apps/impress/src/features/auth/index.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
export * from './api/types';
|
||||||
|
export * from './components';
|
||||||
|
export * from './stores';
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
export * from './useAuthStore';
|
||||||
@@ -3,8 +3,8 @@ import { create } from 'zustand';
|
|||||||
import { baseApiUrl } from '@/api';
|
import { baseApiUrl } from '@/api';
|
||||||
import { terminateCrispSession } from '@/services';
|
import { terminateCrispSession } from '@/services';
|
||||||
|
|
||||||
import { User, getMe } from './api';
|
import { User, getMe } from '../api';
|
||||||
import { PATH_AUTH_LOCAL_STORAGE } from './conf';
|
import { PATH_AUTH_LOCAL_STORAGE } from '../conf';
|
||||||
|
|
||||||
interface AuthStore {
|
interface AuthStore {
|
||||||
initiated: boolean;
|
initiated: boolean;
|
||||||
@@ -10,7 +10,7 @@ import { css } from 'styled-components';
|
|||||||
import * as Y from 'yjs';
|
import * as Y from 'yjs';
|
||||||
|
|
||||||
import { Box, TextErrors } from '@/components';
|
import { Box, TextErrors } from '@/components';
|
||||||
import { useAuthStore } from '@/core/auth';
|
import { useAuthStore } from '@/features/auth';
|
||||||
import { Doc } from '@/features/docs/doc-management';
|
import { Doc } from '@/features/docs/doc-management';
|
||||||
|
|
||||||
import { useUploadFile } from '../hook';
|
import { useUploadFile } from '../hook';
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { User } from '@/core';
|
import { User } from '@/features/auth';
|
||||||
|
|
||||||
export interface Access {
|
export interface Access {
|
||||||
id: string;
|
id: string;
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||||
import { User } from '@/core/auth';
|
import { User } from '@/features/auth';
|
||||||
import {
|
import {
|
||||||
Access,
|
Access,
|
||||||
Doc,
|
Doc,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { APIError, errorCauses, fetchAPI } from '@/api';
|
import { APIError, errorCauses, fetchAPI } from '@/api';
|
||||||
import { User } from '@/core/auth';
|
import { User } from '@/features/auth';
|
||||||
import { Doc, Role } from '@/features/docs/doc-management';
|
import { Doc, Role } from '@/features/docs/doc-management';
|
||||||
import { Invitation, OptionType } from '@/features/docs/doc-share/types';
|
import { Invitation, OptionType } from '@/features/docs/doc-share/types';
|
||||||
import { ContentLanguage } from '@/i18n/types';
|
import { ContentLanguage } from '@/i18n/types';
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
|
import { UseQueryOptions, useQuery } from '@tanstack/react-query';
|
||||||
|
|
||||||
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
import { APIError, APIList, errorCauses, fetchAPI } from '@/api';
|
||||||
import { User } from '@/core/auth';
|
import { User } from '@/features/auth';
|
||||||
import { Doc } from '@/features/docs/doc-management';
|
import { Doc } from '@/features/docs/doc-management';
|
||||||
|
|
||||||
export type UsersParams = {
|
export type UsersParams = {
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import { css } from 'styled-components';
|
|||||||
|
|
||||||
import { APIError } from '@/api';
|
import { APIError } from '@/api';
|
||||||
import { Box } from '@/components';
|
import { Box } from '@/components';
|
||||||
import { User } from '@/core';
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { User } from '@/features/auth';
|
||||||
import { Doc, Role } from '@/features/docs';
|
import { Doc, Role } from '@/features/docs';
|
||||||
import { useLanguage } from '@/i18n/hooks/useLanguage';
|
import { useLanguage } from '@/i18n/hooks/useLanguage';
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import { Button } from '@openfun/cunningham-react';
|
|||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
import { Box, Icon, Text } from '@/components';
|
import { Box, Icon, Text } from '@/components';
|
||||||
import { User } from '@/core';
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { User } from '@/features/auth';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: User;
|
user: User;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import {
|
|||||||
DropdownMenuOption,
|
DropdownMenuOption,
|
||||||
IconOptions,
|
IconOptions,
|
||||||
} from '@/components';
|
} from '@/components';
|
||||||
import { User } from '@/core';
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { User } from '@/features/auth';
|
||||||
import { Doc, Role } from '@/features/docs/doc-management';
|
import { Doc, Role } from '@/features/docs/doc-management';
|
||||||
|
|
||||||
import { useDeleteDocInvitation, useUpdateDocInvitation } from '../api';
|
import { useDeleteDocInvitation, useUpdateDocInvitation } from '../api';
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
QuickSearchData,
|
QuickSearchData,
|
||||||
QuickSearchGroup,
|
QuickSearchGroup,
|
||||||
} from '@/components/quick-search/';
|
} from '@/components/quick-search/';
|
||||||
import { User } from '@/core';
|
import { User } from '@/features/auth';
|
||||||
import { Access, Doc } from '@/features/docs';
|
import { Access, Doc } from '@/features/docs';
|
||||||
import { useResponsiveStore } from '@/stores';
|
import { useResponsiveStore } from '@/stores';
|
||||||
import { isValidEmail } from '@/utils';
|
import { isValidEmail } from '@/utils';
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
import { Box, Icon, Text } from '@/components';
|
import { Box, Icon, Text } from '@/components';
|
||||||
import { User } from '@/core';
|
import { User } from '@/features/auth';
|
||||||
|
|
||||||
import { SearchUserRow } from './SearchUserRow';
|
import { SearchUserRow } from './SearchUserRow';
|
||||||
|
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import {
|
|||||||
QuickSearchItemContent,
|
QuickSearchItemContent,
|
||||||
QuickSearchItemContentProps,
|
QuickSearchItemContentProps,
|
||||||
} from '@/components/quick-search';
|
} from '@/components/quick-search';
|
||||||
import { User } from '@/core';
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { User } from '@/features/auth';
|
||||||
|
|
||||||
import { UserAvatar } from './UserAvatar';
|
import { UserAvatar } from './UserAvatar';
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
import { Box } from '@/components';
|
import { Box } from '@/components';
|
||||||
import { User } from '@/core';
|
|
||||||
import { tokens } from '@/cunningham';
|
import { tokens } from '@/cunningham';
|
||||||
|
import { User } from '@/features/auth';
|
||||||
|
|
||||||
const colors = tokens.themes.default.theme.colors;
|
const colors = tokens.themes.default.theme.colors;
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { useAuthStore } from '@/core/auth';
|
import { useAuthStore } from '@/features/auth';
|
||||||
import { Access, Role } from '@/features/docs/doc-management';
|
import { Access, Role } from '@/features/docs/doc-management';
|
||||||
|
|
||||||
export const useWhoAmI = (access: Access) => {
|
export const useWhoAmI = (access: Access) => {
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { User } from '@/core/auth';
|
import { User } from '@/features/auth';
|
||||||
import { Role } from '@/features/docs';
|
import { Role } from '@/features/docs';
|
||||||
|
|
||||||
export interface Invitation {
|
export interface Invitation {
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { useTranslation } from 'react-i18next';
|
|||||||
import { css } from 'styled-components';
|
import { css } from 'styled-components';
|
||||||
|
|
||||||
import { Box, Icon, StyledLink } from '@/components/';
|
import { Box, Icon, StyledLink } from '@/components/';
|
||||||
import { ButtonLogin } from '@/core/auth';
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { ButtonLogin } from '@/features/auth';
|
||||||
import { LanguagePicker } from '@/features/language';
|
import { LanguagePicker } from '@/features/language';
|
||||||
import { useLeftPanelStore } from '@/features/left-panel';
|
import { useLeftPanelStore } from '@/features/left-panel';
|
||||||
import { useResponsiveStore } from '@/stores';
|
import { useResponsiveStore } from '@/stores';
|
||||||
|
|||||||
@@ -3,8 +3,8 @@ import { useCallback, useEffect } from 'react';
|
|||||||
import { createGlobalStyle, css } from 'styled-components';
|
import { createGlobalStyle, css } from 'styled-components';
|
||||||
|
|
||||||
import { Box, SeparatedSection } from '@/components';
|
import { Box, SeparatedSection } from '@/components';
|
||||||
import { ButtonLogin } from '@/core';
|
|
||||||
import { useCunninghamTheme } from '@/cunningham';
|
import { useCunninghamTheme } from '@/cunningham';
|
||||||
|
import { ButtonLogin } from '@/features/auth';
|
||||||
import { HEADER_HEIGHT } from '@/features/header/conf';
|
import { HEADER_HEIGHT } from '@/features/header/conf';
|
||||||
import { LanguagePicker } from '@/features/language';
|
import { LanguagePicker } from '@/features/language';
|
||||||
import { useResponsiveStore } from '@/stores';
|
import { useResponsiveStore } from '@/stores';
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { useRouter } from 'next/navigation';
|
|||||||
import { PropsWithChildren } from 'react';
|
import { PropsWithChildren } from 'react';
|
||||||
|
|
||||||
import { Box, Icon, SeparatedSection } from '@/components';
|
import { Box, Icon, SeparatedSection } from '@/components';
|
||||||
import { useAuthStore } from '@/core';
|
import { useAuthStore } from '@/features/auth';
|
||||||
import { useCreateDoc } from '@/features/docs/doc-management';
|
import { useCreateDoc } from '@/features/docs/doc-management';
|
||||||
import { DocSearchModal } from '@/features/docs/doc-search';
|
import { DocSearchModal } from '@/features/docs/doc-search';
|
||||||
import { useCmdK } from '@/hook/useCmdK';
|
import { useCmdK } from '@/hook/useCmdK';
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useRouter } from 'next/router';
|
|||||||
import { useEffect, useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
|
|
||||||
import { Box, Text, TextErrors } from '@/components';
|
import { Box, Text, TextErrors } from '@/components';
|
||||||
import { useAuthStore } from '@/core/auth';
|
import { useAuthStore } from '@/features/auth';
|
||||||
import { DocEditor } from '@/features/docs/doc-editor';
|
import { DocEditor } from '@/features/docs/doc-editor';
|
||||||
import {
|
import {
|
||||||
Doc,
|
Doc,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
import { Crisp } from 'crisp-sdk-web';
|
import { Crisp } from 'crisp-sdk-web';
|
||||||
|
|
||||||
import { User } from '@/core';
|
import { User } from '@/features/auth';
|
||||||
|
|
||||||
export const initializeCrispSession = (user: User) => {
|
export const initializeCrispSession = (user: User) => {
|
||||||
if (!Crisp.isCrispInjected()) {
|
if (!Crisp.isCrispInjected()) {
|
||||||
|
|||||||
Reference in New Issue
Block a user