|
@@ -17,6 +17,7 @@ import {
|
17
|
17
|
setUserConnected
|
18
|
18
|
} from '../action-creator.sync.js'
|
19
|
19
|
import { COOKIE, PAGE } from '../helper.js'
|
|
20
|
+import { Checkbox } from 'tracim_frontend_lib'
|
20
|
21
|
|
21
|
22
|
class Login extends React.Component {
|
22
|
23
|
constructor (props) {
|
|
@@ -36,7 +37,11 @@ class Login extends React.Component {
|
36
|
37
|
|
37
|
38
|
handleChangeLogin = e => this.setState({inputLogin: {...this.state.inputLogin, value: e.target.value}})
|
38
|
39
|
handleChangePassword = e => this.setState({inputPassword: {...this.state.inputPassword, value: e.target.value}})
|
39
|
|
- handleChangeRememberMe = () => this.setState(prev => ({inputRememberMe: !prev.inputRememberMe}))
|
|
40
|
+ handleChangeRememberMe = e => {
|
|
41
|
+ e.preventDefault()
|
|
42
|
+ e.stopPropagation()
|
|
43
|
+ this.setState(prev => ({inputRememberMe: !prev.inputRememberMe}))
|
|
44
|
+ }
|
40
|
45
|
|
41
|
46
|
handleClickSubmit = async () => {
|
42
|
47
|
const { history, dispatch, t } = this.props
|
|
@@ -52,8 +57,13 @@ class Login extends React.Component {
|
52
|
57
|
logged: true
|
53
|
58
|
}))
|
54
|
59
|
|
55
|
|
- Cookies.set(COOKIE.USER_LOGIN, inputLogin.value)
|
56
|
|
- Cookies.set(COOKIE.USER_AUTH, userAuth)
|
|
60
|
+ if (inputRememberMe) {
|
|
61
|
+ Cookies.set(COOKIE.USER_LOGIN, inputLogin.value, {expires: 365})
|
|
62
|
+ Cookies.set(COOKIE.USER_AUTH, userAuth, {expires: 365})
|
|
63
|
+ } else {
|
|
64
|
+ Cookies.set(COOKIE.USER_LOGIN, inputLogin.value)
|
|
65
|
+ Cookies.set(COOKIE.USER_AUTH, userAuth)
|
|
66
|
+ }
|
57
|
67
|
|
58
|
68
|
history.push(PAGE.WORKSPACE.ROOT)
|
59
|
69
|
} else if (fetchPostUserLogin.status === 403) {
|
|
@@ -103,32 +113,30 @@ class Login extends React.Component {
|
103
|
113
|
/>
|
104
|
114
|
|
105
|
115
|
<div className='row align-items-center mt-4 mb-4'>
|
106
|
|
-
|
107
|
|
- {/*
|
108
|
|
- <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
|
109
|
|
- <InputCheckbox
|
110
|
|
- parentClassName='connection__form__rememberme'
|
111
|
|
- customClass=''
|
112
|
|
- label='Se souvenir de moi'
|
|
116
|
+ <div className='col-12 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
|
|
117
|
+ <div className='connection__form__rememberme' onClick={this.handleChangeRememberMe}>
|
|
118
|
+ <Checkbox
|
|
119
|
+ name='inputRememberMe'
|
113
|
120
|
checked={this.state.inputRememberMe}
|
114
|
|
- onChange={this.handleChangeRememberMe}
|
115
|
121
|
/>
|
|
122
|
+ Se souvenir de moi
|
116
|
123
|
</div>
|
117
|
|
- */}
|
118
|
124
|
|
119
|
|
- <div className='col-6 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
|
120
|
125
|
<LoginBtnForgotPw
|
121
|
126
|
customClass='connection__form__pwforgot'
|
122
|
127
|
label={this.props.t('Forgotten password ?')}
|
123
|
128
|
/>
|
124
|
129
|
</div>
|
125
|
|
- <Button
|
126
|
|
- htmlType='button'
|
127
|
|
- bootstrapType='primary'
|
128
|
|
- customClass='connection__form__btnsubmit ml-auto'
|
129
|
|
- label={this.props.t('Connection')}
|
130
|
|
- onClick={this.handleClickSubmit}
|
131
|
|
- />
|
|
130
|
+
|
|
131
|
+ <div className='col-6 col-sm-6 col-md-6 col-lg-6 col-xl-6'>
|
|
132
|
+ <Button
|
|
133
|
+ htmlType='button'
|
|
134
|
+ bootstrapType='primary'
|
|
135
|
+ customClass='connection__form__btnsubmit ml-auto'
|
|
136
|
+ label={this.props.t('Connection')}
|
|
137
|
+ onClick={this.handleClickSubmit}
|
|
138
|
+ />
|
|
139
|
+ </div>
|
132
|
140
|
</div>
|
133
|
141
|
</div>
|
134
|
142
|
|