|
@@ -26,6 +26,37 @@ class Connection extends Component {
|
26
|
26
|
}
|
27
|
27
|
|
28
|
28
|
handleSubmit = (event) => {
|
|
29
|
+ if (this.props.forJamalette){
|
|
30
|
+ this.handleSubmitJamalette(event)
|
|
31
|
+ }else{
|
|
32
|
+ this.handleSubmitLogin(event)
|
|
33
|
+ }
|
|
34
|
+ }
|
|
35
|
+
|
|
36
|
+ handleSubmitJamalette = (event) => {
|
|
37
|
+ event.preventDefault()
|
|
38
|
+ console.log(this.state.password);
|
|
39
|
+
|
|
40
|
+ let bodyFormData = new FormData();
|
|
41
|
+ bodyFormData.set('identifyer',"jamalette");
|
|
42
|
+ bodyFormData.set('password',this.state.password)
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+ axios.post('https://etud.insa-toulouse.fr/~proximo/v2/api/login',bodyFormData)
|
|
46
|
+ .then(res => {
|
|
47
|
+ sessionStorage.setItem('token_jamalette',res.data.api_token)
|
|
48
|
+ this.setState({redirect:true})
|
|
49
|
+ console.log(res.data.api_token);
|
|
50
|
+ })
|
|
51
|
+ .catch(error => {
|
|
52
|
+ if(error.response.status === 401){
|
|
53
|
+ this.setState({errors:error.response.data.errors})
|
|
54
|
+ }
|
|
55
|
+ console.log(error.response);
|
|
56
|
+ })
|
|
57
|
+ }
|
|
58
|
+
|
|
59
|
+ handleSubmitLogin = (event) => {
|
29
|
60
|
event.preventDefault()
|
30
|
61
|
console.log(this.state.password);
|
31
|
62
|
|
|
@@ -33,9 +64,10 @@ class Connection extends Component {
|
33
|
64
|
bodyFormData.set('identifyer',this.state.identifyer);
|
34
|
65
|
bodyFormData.set('password',this.state.password)
|
35
|
66
|
|
|
67
|
+
|
36
|
68
|
axios.post('https://etud.insa-toulouse.fr/~proximo/v2/api/login',bodyFormData)
|
37
|
69
|
.then(res => {
|
38
|
|
- sessionStorage.setItem('token',res.data.api_token)
|
|
70
|
+ sessionStorage.setItem('token_login',res.data.api_token)
|
39
|
71
|
this.setState({redirect:true})
|
40
|
72
|
console.log(res.data.api_token);
|
41
|
73
|
})
|
|
@@ -45,6 +77,7 @@ class Connection extends Component {
|
45
|
77
|
}
|
46
|
78
|
console.log(error.response);
|
47
|
79
|
})
|
|
80
|
+
|
48
|
81
|
}
|
49
|
82
|
|
50
|
83
|
render() {
|
|
@@ -55,13 +88,14 @@ class Connection extends Component {
|
55
|
88
|
<div id="transp">
|
56
|
89
|
<div id="formBody">
|
57
|
90
|
<div id="formHead">
|
58
|
|
- <div id="formHeadTxt">Connexion</div>
|
|
91
|
+ <div id="formHeadTxt">{this.props.title}</div>
|
59
|
92
|
<div id="crossClose" onClick={this.props.handleCloseAbove}>
|
60
|
93
|
<Icon icon={plusIcon} style={{transform : 'rotate(-45deg)', color: '#ffffff', fontSize: '3vw'}} />
|
61
|
94
|
</div>
|
62
|
95
|
</div>
|
63
|
96
|
<div id="formMainContent">
|
64
|
97
|
<form method='POST' onSubmit={this.handleSubmit}>
|
|
98
|
+ {!this.props.forJamalette ?
|
65
|
99
|
<div id="identifyerBlock">
|
66
|
100
|
<div id="identifyerBlockInput">
|
67
|
101
|
<label htmlFor="identifyerBox">Identifiant</label>
|
|
@@ -70,7 +104,7 @@ class Connection extends Component {
|
70
|
104
|
<div id="errorIdentifyerBlock">
|
71
|
105
|
<p id="errorIdentifyer">{this.state.errors.identifyer}</p>
|
72
|
106
|
</div>
|
73
|
|
- </div>
|
|
107
|
+ </div> : null }
|
74
|
108
|
<div id="passwordBlock">
|
75
|
109
|
<div id="passwordBlockInput">
|
76
|
110
|
<label htmlFor="passwordBox">Mot de Passe</label>
|