Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
Drip
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
backup
Drip
Commits
857b8fc1
Commit
857b8fc1
authored
6 years ago
by
mashazyu
Browse files
Options
Downloads
Patches
Plain Diff
Cleanup ChangePassword component
parent
7ddf9a70
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
components/settings/password/create.js
+1
-5
1 addition, 5 deletions
components/settings/password/create.js
components/settings/password/update.js
+71
-59
71 additions, 59 deletions
components/settings/password/update.js
with
72 additions
and
64 deletions
components/settings/password/create.js
+
1
−
5
View file @
857b8fc1
...
@@ -59,11 +59,7 @@ export default class CreatePassword extends Component {
...
@@ -59,11 +59,7 @@ export default class CreatePassword extends Component {
}
}
handleConfirmationInput
=
(
passwordConfirmation
)
=>
{
handleConfirmationInput
=
(
passwordConfirmation
)
=>
{
const
{
password
}
=
this
.
state
this
.
setState
({
passwordConfirmation
})
this
.
setState
({
passwordConfirmation
,
isPasswordsMatch
:
passwordConfirmation
===
password
})
}
}
render
()
{
render
()
{
...
...
This diff is collapsed.
Click to expand it.
components/settings/password/update.js
+
71
−
59
View file @
857b8fc1
import
React
,
{
Component
}
from
'
react
'
import
React
,
{
Component
}
from
'
react
'
import
{
import
{
View
}
from
'
react-native
'
View
,
TouchableOpacity
}
from
'
react-native
'
import
nodejs
from
'
nodejs-mobile-react-native
'
import
nodejs
from
'
nodejs-mobile-react-native
'
import
AppText
from
'
../../app-text
'
import
{
shared
as
sharedLabels
}
from
'
../../../i18n/en/labels
'
import
styles
from
'
../../../styles
'
import
{
settings
}
from
'
../../../i18n/en/settings
'
import
{
shared
}
from
'
../../../i18n/en/labels
'
import
{
settings
as
labels
}
from
'
../../../i18n/en/settings
'
import
{
requestHash
,
changeEncryptionAndRestartApp
}
from
'
../../../db
'
import
{
requestHash
,
changeEncryptionAndRestartApp
}
from
'
../../../db
'
import
PasswordField
from
'
./password-field
'
import
PasswordField
from
'
./password-field
'
import
SettingsButton
from
'
./settings-button
'
import
SettingsButton
from
'
./settings-button
'
...
@@ -19,10 +14,11 @@ export default class ChangePassword extends Component {
...
@@ -19,10 +14,11 @@ export default class ChangePassword extends Component {
constructor
()
{
constructor
()
{
super
()
super
()
this
.
state
=
{
this
.
state
=
{
enteringCurrentPassword
:
false
,
currentPassword
:
null
,
currentPassword
:
null
,
enteringNewPassword
:
false
,
newPassword
:
null
,
newPassword
:
null
newPasswordConfirmation
:
null
,
enteringCurrentPassword
:
false
,
enteringNewPassword
:
false
}
}
nodejs
.
channel
.
addListener
(
nodejs
.
channel
.
addListener
(
...
@@ -55,9 +51,9 @@ export default class ChangePassword extends Component {
...
@@ -55,9 +51,9 @@ export default class ChangePassword extends Component {
if
(
passwordCorrect
)
{
if
(
passwordCorrect
)
{
this
.
setState
({
this
.
setState
({
enteringCurrentPassword
:
false
,
currentPassword
:
null
,
currentPassword
:
null
,
enteringNewPassword
:
true
enteringNewPassword
:
true
,
enteringCurrentPassword
:
false
})
})
}
}
}
}
...
@@ -68,61 +64,77 @@ export default class ChangePassword extends Component {
...
@@ -68,61 +64,77 @@ export default class ChangePassword extends Component {
})
})
}
}
handleCurrentPasswordInput
=
(
currentPassword
)
=>
{
this
.
setState
({
currentPassword
})
}
checkCurrentPassword
=
()
=>
{
requestHash
(
'
pre-change-pw-check
'
,
this
.
state
.
currentPassword
)
}
handleNewPasswordInput
=
(
newPassword
)
=>
{
this
.
setState
({
newPassword
})
}
changePassword
=
()
=>
{
requestHash
(
'
change-pw
'
,
this
.
state
.
newPassword
)
}
render
()
{
render
()
{
return
(
<
View
>
const
{
{
!
this
.
state
.
enteringCurrentPassword
&&
enteringCurrentPassword
,
!
this
.
state
.
enteringNewPassword
&&
enteringNewPassword
,
<
SettingsButton
currentPassword
,
onPress
=
{
this
.
startChangingPassword
}
newPassword
disabled
=
{
this
.
state
.
currentPassword
}
}
=
this
.
state
>
{
labels
.
passwordSettings
.
changePassword
}
const
labels
=
settings
.
passwordSettings
<
/SettingsButton
>
}
if
(
enteringCurrentPassword
)
{
return
(
{
this
.
state
.
enteringCurrentPassword
&&
<
View
>
<
View
>
<
PasswordField
<
PasswordField
placeholder
=
{
labels
.
enterCurrent
}
onChangeText
=
{
val
=>
{
value
=
{
currentPassword
}
this
.
setState
({
onChangeText
=
{
this
.
handleCurrentPasswordInput
}
currentPassword
:
val
,
/
>
wrongPassword
:
false
<
SettingsButton
})
onPress
=
{
this
.
checkCurrentPassword
}
}}
disabled
=
{
!
currentPassword
}
value
=
{
this
.
state
.
currentPassword
}
>
placeholder
=
{
labels
.
passwordSettings
.
enterCurrent
}
{
sharedLabels
.
unlock
}
/
>
<
/SettingsButton
>
<
SettingsButton
<
/View
>
onPress
=
{()
=>
requestHash
(
'
pre-change-pw-check
'
,
this
.
state
.
currentPassword
)}
)
disabled
=
{
!
this
.
state
.
currentPassword
}
}
>
{
shared
.
unlock
}
if
(
enteringNewPassword
)
{
<
/SettingsButton
>
return
(
<
/View
>
}
{
this
.
state
.
enteringNewPassword
&&
<
View
>
<
View
>
<
PasswordField
<
PasswordField
style
=
{
styles
.
passwordField
}
placeholder
=
{
labels
.
enterNew
}
onChangeText
=
{
val
=>
{
value
=
{
newPassword
}
this
.
setState
({
onChangeText
=
{
this
.
handleNewPasswordInput
}
newPassword
:
val
})
}}
value
=
{
this
.
state
.
changedPassword
}
placeholder
=
{
labels
.
passwordSettings
.
enterNew
}
/
>
/
>
<
SettingsButton
<
SettingsButton
onPress
=
{
()
=>
requestHash
(
'
change-pw
'
,
this
.
state
.
new
Password
)
}
onPress
=
{
this
.
change
Password
}
disabled
=
{
!
this
.
state
.
newPassword
}
disabled
=
{
!
newPassword
}
>
>
{
labels
.
passwordSettings
.
changePassword
}
{
labels
.
changePassword
}
<
/SettingsButton
>
<
/SettingsButton
>
<
/View
>
<
/View
>
}
)
}
return
(
<
View
>
<
SettingsButton
onPress
=
{
this
.
startChangingPassword
}
disabled
=
{
currentPassword
}
>
{
labels
.
changePassword
}
<
/SettingsButton
>
<
/View
>
<
/View
>
)
)
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment