Format all files with no breaking changes
Lint all files using `npm run lint -- --fix`.
Format all files using `prettier --write "**/*.{ts,tsx,js,jsx,json}"`
No breaking change, only code style is modified.
Gitlab: #29
Change-Id: I4f034a7fb4d3eea10bcd3e38b44a65a1046de62f
diff --git a/client/src/pages/loginDialog.jsx b/client/src/pages/loginDialog.jsx
index ef647e8..9a7ff0c 100644
--- a/client/src/pages/loginDialog.jsx
+++ b/client/src/pages/loginDialog.jsx
@@ -1,4 +1,4 @@
-import { Component } from 'react'
+import { Component } from 'react';
import Button from '@mui/material/Button';
import TextField from '@mui/material/TextField';
@@ -11,48 +11,49 @@
import DialogActions from '@mui/material/DialogActions';
import DialogContent from '@mui/material/DialogContent';
-import authManager from '../AuthManager'
+import authManager from '../AuthManager';
function Copyright() {
- return (
- <Typography variant="body2" color="textSecondary" align="center">
- {'Copyright © 2016-'}{new Date().getFullYear()}{' Savoir-faire Linux Inc.'}
- <Link color="inherit" href="https://jami.net/">
- Jami.net
- </Link>{' '}
- {'.'}
- </Typography>
- );
+ return (
+ <Typography variant="body2" color="textSecondary" align="center">
+ {'Copyright © 2016-'}
+ {new Date().getFullYear()}
+ {' Savoir-faire Linux Inc.'}
+ <Link color="inherit" href="https://jami.net/">
+ Jami.net
+ </Link>{' '}
+ {'.'}
+ </Typography>
+ );
}
class SignInPage extends Component {
+ constructor(props) {
+ console.log('SignInPage ' + props.open);
+ super(props);
+ this.state = {
+ submitted: false,
+ loading: false,
+ };
+ this.handleSubmit = this.handleSubmit.bind(this);
+ this.localLogin = this.localLogin.bind(this);
+ }
- constructor(props) {
- console.log("SignInPage " + props.open)
- super(props)
- this.state = {
- submitted: false,
- loading: false,
- }
- this.handleSubmit = this.handleSubmit.bind(this);
- this.localLogin = this.localLogin.bind(this);
- }
+ handleusername(text) {
+ this.setState({ username: text.target.value });
+ }
- handleusername(text) {
- this.setState({ username: text.target.value })
- }
+ handlePassword(text) {
+ this.setState({ password: text.target.value });
+ }
- handlePassword(text) {
- this.setState({ password: text.target.value })
- }
-
- localLogin() {
- this.setState({
- submitted: true,
- loading: true
- })
- authManager.authenticate('admin', 'admin')
- /*fetch('/api/localLogin?username=none&password=none', {
+ localLogin() {
+ this.setState({
+ submitted: true,
+ loading: true,
+ });
+ authManager.authenticate('admin', 'admin');
+ /*fetch('/api/localLogin?username=none&password=none', {
header: { "Content-Type": "application/json" },
method: "POST",
credentials: 'same-origin'
@@ -80,111 +81,109 @@
errorMessage: e.toString()
})
})*/
- }
+ }
- handleSubmit(event) {
- event.preventDefault();
- let obj = {}
- obj.username = this.state.username;
- obj.password = this.state.password;
+ handleSubmit(event) {
+ event.preventDefault();
+ let obj = {};
+ obj.username = this.state.username;
+ obj.password = this.state.password;
+ this.setState({
+ submitted: true,
+ loading: true,
+ });
+
+ fetch('/api/login?username=' + obj.username + '&password=' + obj.password, {
+ header: {
+ 'Content-Type': 'application/json',
+ },
+ method: 'POST',
+ credentials: 'same-origin',
+ //body: JSON.stringify({ obj })
+ })
+ .then((res) => {
+ if (res.status === '200') {
+ this.setState({
+ redirect: true,
+ });
+ } else if (res.status === '401') {
+ this.setState({
+ loading: false,
+ error: true,
+ open: true,
+ errorMessage: 'Wrong credentials! Your are not allowed to connect',
+ });
+ }
+ //this.setState({ session: res });
+ })
+ .catch((e) => {
this.setState({
- submitted: true,
- loading: true
- })
+ loading: false,
+ error: true,
+ open: true,
+ errorMessage: e.toString(),
+ });
+ });
+ }
- fetch('/api/login?username=' + obj.username + '&password=' + obj.password,
- {
- header: {
- "Content-Type": "application/json"
- },
- method: "POST",
- credentials: 'same-origin'
- //body: JSON.stringify({ obj })
- }
- ).then((res) => {
- if (res.status === '200') {
- this.setState({
- redirect: true
- });
- } else if (res.status === '401') {
- this.setState({
- loading: false,
- error: true,
- open: true,
- errorMessage: "Wrong credentials! Your are not allowed to connect"
- })
- }
- //this.setState({ session: res });
- }).catch((e) => {
- this.setState({
- loading: false,
- error: true,
- open: true,
- errorMessage: e.toString()
- })
- })
- }
+ render() {
+ console.log('SignInPage render ' + this.props.open);
+ return (
+ <Dialog open={this.props.open}>
+ <DialogTitle>Se connecter</DialogTitle>
+ <DialogContent>
+ <Button
+ type="submit"
+ fullWidth
+ variant="contained"
+ color="primary"
+ className="" /*{classes.submit}*/
+ onClick={() => {
+ this.localLogin();
+ }}
+ >
+ Compte local
+ </Button>
+ <TextField
+ variant="outlined"
+ margin="normal"
+ required
+ fullWidth
+ id="username"
+ label="LDAP Savoir-faire Linux"
+ name="username"
+ autoComplete="email"
+ autoFocus
+ onChange={(text) => {
+ this.handleusername(text);
+ }}
+ />
+ <TextField
+ variant="outlined"
+ margin="normal"
+ required
+ fullWidth
+ name="password"
+ label="Mot de passe"
+ type="password"
+ id="password"
+ autoComplete="current-password"
+ onChange={(text) => {
+ this.handlePassword(text);
+ }}
+ />
+ <FormControlLabel control={<Checkbox value="remember" color="primary" />} label="Se rapeller de moi" />
+ </DialogContent>
- render() {
- console.log("SignInPage render " + this.props.open)
- return (
- <Dialog open={this.props.open}>
- <DialogTitle>Se connecter</DialogTitle>
- <DialogContent>
- <Button
- type="submit"
- fullWidth
- variant="contained"
- color="primary"
- className=""/*{classes.submit}*/
- onClick={() => { this.localLogin() }}
- >
- Compte local
- </Button>
- <TextField
- variant="outlined"
- margin="normal"
- required
- fullWidth
- id="username"
- label="LDAP Savoir-faire Linux"
- name="username"
- autoComplete="email"
- autoFocus
- onChange={(text) => { this.handleusername(text) }}
- />
- <TextField
- variant="outlined"
- margin="normal"
- required
- fullWidth
- name="password"
- label="Mot de passe"
- type="password"
- id="password"
- autoComplete="current-password"
- onChange={(text) => { this.handlePassword(text) }}
- />
- <FormControlLabel
- control={<Checkbox value="remember" color="primary" />}
- label="Se rapeller de moi"
- />
- </DialogContent>
-
- <DialogActions>
- <Button
- type="submit"
- size="medium"
- onClick={this.handleSubmit}
- >
- Se connecter
- </Button>
- </DialogActions>
- </Dialog>
- );
- }
+ <DialogActions>
+ <Button type="submit" size="medium" onClick={this.handleSubmit}>
+ Se connecter
+ </Button>
+ </DialogActions>
+ </Dialog>
+ );
+ }
}
-
-export default SignInPage;
\ No newline at end of file
+export default SignInPage;