mirror of
https://github.com/hedgedoc/hedgedoc.git
synced 2025-06-08 02:15:02 -04:00
Frontend config and Loader component (#12)
* Add FrontendConfig and Loader Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Merge more setup into the application loader Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Rename config files Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Remove blank line Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Fix url Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Make strings more specific Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Restructure store use Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * split methods and actions Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * extract code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * remove actions.ts Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * add reason and rename component Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * remove unused call Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use redux store in api Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * activate email in backend config Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * add new line Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * reduce code Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Make error more specific Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Use expectedResponseCode Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> * Update src/redux/backend-config/types.ts Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Update src/components/application-loader/application-loader.tsx Co-authored-by: Philip Molares <git@molar.es> * Use fragment Signed-off-by: Tilman Vatteroth <tilman.vatteroth@tu-dortmund.de> Co-authored-by: Philip Molares <git@molar.es>
This commit is contained in:
parent
ef17c7acbb
commit
a490e1240b
36 changed files with 425 additions and 256 deletions
|
@ -1,13 +1,11 @@
|
|||
import {Trans, useTranslation} from "react-i18next";
|
||||
import {Button, Form, Alert} from "react-bootstrap";
|
||||
import {Alert, Button, Form} from "react-bootstrap";
|
||||
import React, {Fragment, useState} from "react";
|
||||
import {postEmailLogin} from "../../../../../api/user";
|
||||
import {useDispatch} from "react-redux";
|
||||
import {getAndSetUser} from "../../../../initialize/initialize-user-state-from-api";
|
||||
import {getAndSetUser} from "../../../../../utils/apiUtils";
|
||||
|
||||
const ViaEMail: React.FC = () => {
|
||||
const {t} = useTranslation();
|
||||
const dispatch = useDispatch();
|
||||
const [email, setEmail] = useState("");
|
||||
const [password, setPassword] = useState("");
|
||||
const [error, setError] = useState(false);
|
||||
|
@ -15,10 +13,11 @@ const ViaEMail: React.FC = () => {
|
|||
postEmailLogin(email, password)
|
||||
.then(loginJson => {
|
||||
console.log(loginJson)
|
||||
getAndSetUser(dispatch);
|
||||
}).catch(_reason => {
|
||||
getAndSetUser();
|
||||
}).catch(_reason => {
|
||||
setError(true);
|
||||
})
|
||||
}
|
||||
)
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
|
@ -55,8 +54,7 @@ const ViaEMail: React.FC = () => {
|
|||
<Button
|
||||
type="submit"
|
||||
size="sm"
|
||||
variant="primary"
|
||||
>
|
||||
variant="primary">
|
||||
<Trans i18nKey="signIn"/>
|
||||
</Button>
|
||||
</Form>
|
||||
|
@ -64,4 +62,4 @@ const ViaEMail: React.FC = () => {
|
|||
);
|
||||
}
|
||||
|
||||
export { ViaEMail }
|
||||
export {ViaEMail}
|
||||
|
|
|
@ -9,7 +9,7 @@ import {ApplicationState} from "../../../../redux";
|
|||
|
||||
const Login: React.FC = () => {
|
||||
useTranslation();
|
||||
const authProviders = useSelector((state: ApplicationState) => state.applicationConfig.authProviders);
|
||||
const authProviders = useSelector((state: ApplicationState) => state.backendConfig.authProviders);
|
||||
|
||||
const emailForm = authProviders.email ? <ViaEMail/> : null
|
||||
const ldapForm = authProviders.ldap ? <ViaLdap/> : null
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue