Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
B
Breeze
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DeStream-public
Breeze
Commits
2c54be78
Commit
2c54be78
authored
May 19, 2017
by
dev0tion
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add basic validation to login and recovery components
parent
51d88021
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
98 additions
and
10 deletions
+98
-10
login.component.html
Breeze.UI/src/app/login/login.component.html
+1
-0
login.component.ts
Breeze.UI/src/app/login/login.component.ts
+38
-4
recover.component.html
Breeze.UI/src/app/setup/recover/recover.component.html
+3
-0
recover.component.ts
Breeze.UI/src/app/setup/recover/recover.component.ts
+56
-6
No files found.
Breeze.UI/src/app/login/login.component.html
View file @
2c54be78
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label>
Your password:
</label>
<label>
Your password:
</label>
<input
class=
"form-control"
type=
"password"
formControlName=
"password"
placeholder=
"Enter password here"
>
<input
class=
"form-control"
type=
"password"
formControlName=
"password"
placeholder=
"Enter password here"
>
<div
*
ngIf=
"formErrors.password"
class=
"alert alert-danger"
>
{{formErrors.password}}
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<button
type=
"submit"
[
disabled
]="!
openWalletForm
.
valid
"
class=
"btn btn-success"
>
Decrypt
</button>
<button
type=
"submit"
[
disabled
]="!
openWalletForm
.
valid
"
class=
"btn btn-success"
>
Decrypt
</button>
...
...
Breeze.UI/src/app/login/login.component.ts
View file @
2c54be78
...
@@ -13,10 +13,7 @@ import { WalletLoad } from '../shared/classes/wallet-load';
...
@@ -13,10 +13,7 @@ import { WalletLoad } from '../shared/classes/wallet-load';
})
})
export
class
LoginComponent
implements
OnInit
{
export
class
LoginComponent
implements
OnInit
{
constructor
(
private
globalService
:
GlobalService
,
private
apiService
:
ApiService
,
private
router
:
Router
,
private
fb
:
FormBuilder
)
{
constructor
(
private
globalService
:
GlobalService
,
private
apiService
:
ApiService
,
private
router
:
Router
,
private
fb
:
FormBuilder
)
{
this
.
openWalletForm
=
fb
.
group
({
this
.
buildDecryptForm
();
"selectWallet"
:
[
""
,
Validators
.
required
],
"password"
:
[
""
,
Validators
.
required
]
});
}
}
private
openWalletForm
:
FormGroup
;
private
openWalletForm
:
FormGroup
;
...
@@ -27,6 +24,43 @@ export class LoginComponent implements OnInit {
...
@@ -27,6 +24,43 @@ export class LoginComponent implements OnInit {
this
.
getWalletFiles
();
this
.
getWalletFiles
();
}
}
private
buildDecryptForm
():
void
{
this
.
openWalletForm
=
this
.
fb
.
group
({
"selectWallet"
:
[
""
,
Validators
.
required
],
"password"
:
[
""
,
Validators
.
required
]
});
this
.
openWalletForm
.
valueChanges
.
subscribe
(
data
=>
this
.
onValueChanged
(
data
));
this
.
onValueChanged
();
}
onValueChanged
(
data
?:
any
)
{
if
(
!
this
.
openWalletForm
)
{
return
;
}
const
form
=
this
.
openWalletForm
;
for
(
const
field
in
this
.
formErrors
)
{
this
.
formErrors
[
field
]
=
''
;
const
control
=
form
.
get
(
field
);
if
(
control
&&
control
.
dirty
&&
!
control
.
valid
)
{
const
messages
=
this
.
validationMessages
[
field
];
for
(
const
key
in
control
.
errors
)
{
this
.
formErrors
[
field
]
+=
messages
[
key
]
+
' '
;
}
}
}
}
formErrors
=
{
'password'
:
''
};
validationMessages
=
{
'password'
:
{
'required'
:
'Please enter your password.'
}
};
private
updateWalletFileDisplay
(
walletName
:
string
)
{
private
updateWalletFileDisplay
(
walletName
:
string
)
{
this
.
openWalletForm
.
patchValue
({
selectWallet
:
walletName
})
this
.
openWalletForm
.
patchValue
({
selectWallet
:
walletName
})
}
}
...
...
Breeze.UI/src/app/setup/recover/recover.component.html
View file @
2c54be78
...
@@ -15,14 +15,17 @@
...
@@ -15,14 +15,17 @@
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label>
Mnemonic:
</label>
<label>
Mnemonic:
</label>
<input
class=
"form-control"
formControlName=
"walletMnemonic"
type=
"text"
placeholder=
"Enter your saved mnemonic."
>
<input
class=
"form-control"
formControlName=
"walletMnemonic"
type=
"text"
placeholder=
"Enter your saved mnemonic."
>
<div
*
ngIf=
"formErrors.walletMnemonic"
class=
"alert alert-danger"
>
{{formErrors.walletMnemonic}}
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label>
Wallet password:
</label>
<label>
Wallet password:
</label>
<input
class=
"form-control"
type=
"password"
formControlName=
"walletPassword"
placeholder=
"Enter password here."
>
<input
class=
"form-control"
type=
"password"
formControlName=
"walletPassword"
placeholder=
"Enter password here."
>
<div
*
ngIf=
"formErrors.walletPassword"
class=
"alert alert-danger"
>
{{formErrors.walletPassword}}
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label>
Name:
</label>
<label>
Name:
</label>
<input
class=
"form-control"
formControlName=
"walletName"
type=
"text"
placeholder=
"Enter a name for your wallet."
>
<input
class=
"form-control"
formControlName=
"walletName"
type=
"text"
placeholder=
"Enter a name for your wallet."
>
<div
*
ngIf=
"formErrors.walletName"
class=
"alert alert-danger"
>
{{formErrors.walletName}}
</div>
</div>
</div>
<div
class=
"form-group"
>
<div
class=
"form-group"
>
<label>
Network:
</label>
<label>
Network:
</label>
...
...
Breeze.UI/src/app/setup/recover/recover.component.ts
View file @
2c54be78
...
@@ -15,12 +15,8 @@ import { WalletRecovery } from '../../shared/classes/wallet-recovery';
...
@@ -15,12 +15,8 @@ import { WalletRecovery } from '../../shared/classes/wallet-recovery';
export
class
RecoverComponent
implements
OnInit
{
export
class
RecoverComponent
implements
OnInit
{
constructor
(
private
globalService
:
GlobalService
,
private
apiService
:
ApiService
,
private
router
:
Router
,
private
fb
:
FormBuilder
)
{
constructor
(
private
globalService
:
GlobalService
,
private
apiService
:
ApiService
,
private
router
:
Router
,
private
fb
:
FormBuilder
)
{
this
.
recoverWalletForm
=
fb
.
group
({
this
.
buildRecoverForm
();
"walletMnemonic"
:
[
""
,
Validators
.
required
],
"walletPassword"
:
[
""
,
Validators
.
required
],
"walletName"
:
[
""
,
Validators
.
required
],
"selectNetwork"
:
[
"test"
,
Validators
.
required
]
});
}
}
private
recoverWalletForm
:
FormGroup
;
private
recoverWalletForm
:
FormGroup
;
...
@@ -33,6 +29,60 @@ export class RecoverComponent implements OnInit {
...
@@ -33,6 +29,60 @@ export class RecoverComponent implements OnInit {
ngOnInit
()
{
ngOnInit
()
{
}
}
private
buildRecoverForm
():
void
{
this
.
recoverWalletForm
=
this
.
fb
.
group
({
"walletMnemonic"
:
[
""
,
Validators
.
required
],
"walletPassword"
:
[
""
,
Validators
.
required
],
"walletName"
:
[
""
,
[
Validators
.
required
,
Validators
.
minLength
(
3
),
Validators
.
maxLength
(
24
)
]
],
"selectNetwork"
:
[
"test"
,
Validators
.
required
]
});
this
.
recoverWalletForm
.
valueChanges
.
subscribe
(
data
=>
this
.
onValueChanged
(
data
));
this
.
onValueChanged
();
}
onValueChanged
(
data
?:
any
)
{
if
(
!
this
.
recoverWalletForm
)
{
return
;
}
const
form
=
this
.
recoverWalletForm
;
for
(
const
field
in
this
.
formErrors
)
{
this
.
formErrors
[
field
]
=
''
;
const
control
=
form
.
get
(
field
);
if
(
control
&&
control
.
dirty
&&
!
control
.
valid
)
{
const
messages
=
this
.
validationMessages
[
field
];
for
(
const
key
in
control
.
errors
)
{
this
.
formErrors
[
field
]
+=
messages
[
key
]
+
' '
;
}
}
}
}
formErrors
=
{
'walletMnemonic'
:
''
,
'walletPassword'
:
''
,
'walletName'
:
''
};
validationMessages
=
{
'walletMnemonic'
:
{
'required'
:
'Please enter your 12 word phrase.'
},
'walletPassword'
:
{
'required'
:
'A password is required.'
},
'walletName'
:
{
'required'
:
'Name is required.'
,
'minlength'
:
'Name must be at least 3 characters long.'
,
'maxlength'
:
'Name cannot be more than 24 characters long.'
}
};
private
onBackClicked
()
{
private
onBackClicked
()
{
this
.
router
.
navigate
([
"/setup"
]);
this
.
router
.
navigate
([
"/setup"
]);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment