Commit 2288300a authored by dev0tion's avatar dev0tion

Require creation date on recovery

parent e8433042
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
"testTsconfig": "tsconfig.spec.json", "testTsconfig": "tsconfig.spec.json",
"prefix": "app", "prefix": "app",
"styles": [ "styles": [
"../node_modules/bootstrap/dist/css/bootstrap.min.css", "./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"styles.css" "styles.css"
], ],
"scripts": [], "scripts": [],
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
"electron-context-menu": "0.9.1", "electron-context-menu": "0.9.1",
"enhanced-resolve": "3.3.0", "enhanced-resolve": "3.3.0",
"ngx-clipboard": "8.1.0", "ngx-clipboard": "8.1.0",
"ngx-bootstrap": "1.9.3",
"rxjs": "5.4.3", "rxjs": "5.4.3",
"zone.js": "0.8.17" "zone.js": "0.8.17"
}, },
......
...@@ -12,12 +12,13 @@ ...@@ -12,12 +12,13 @@
<div *ngIf="formErrors.walletName" class="form-control-feedback mt-2">{{ formErrors.walletName }}</div> <div *ngIf="formErrors.walletName" class="form-control-feedback mt-2">{{ formErrors.walletName }}</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-12 row" for="creationDate">Creation Date (optional)</label> <label class="col-12 row" for="creationDate">Creation Date</label>
<material-datepicker class="form-control col-7" [(date)]="creationDate"></material-datepicker> <input type="text" class="form-control" bsDatepicker formControlName="walletDate" placeholder="Select the date your wallet was created." [bsConfig]="bsConfig" [maxDate]="maxDate"/>
<div *ngIf="formErrors.walletDate" class="form-control-feedback mt-2">{{ formErrors.walletDate }}</div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="col-12 row" for="walletMnemonic">12 Secret Words</label> <label class="col-12 row" for="walletMnemonic">Secret Words</label>
<input type="text" class="form-control form-control-success" formControlName="walletMnemonic" id="walletName" placeholder="Enter your 12 secret words."> <input type="text" class="form-control form-control-success" formControlName="walletMnemonic" id="walletName" placeholder="Enter your secret words.">
<div *ngIf="formErrors.walletMnemonic" class="form-control-feedback mt-2">{{ formErrors.walletMnemonic }}</div> <div *ngIf="formErrors.walletMnemonic" class="form-control-feedback mt-2">{{ formErrors.walletMnemonic }}</div>
</div> </div>
<div class="form-group"> <div class="form-group">
...@@ -30,7 +31,6 @@ ...@@ -30,7 +31,6 @@
<select class="form-control custom-select" name="network" formControlName="selectNetwork"> <select class="form-control custom-select" name="network" formControlName="selectNetwork">
<!--<option value="main">Main</option>--> <!--<option value="main">Main</option>-->
<option value="test">Testnet</option> <option value="test">Testnet</option>
<!--<option value="stratistest">StratisTest</option>-->
</select> </select>
</div> </div>
</form> </form>
......
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms'; import { FormGroup, FormControl, Validators, FormBuilder } from '@angular/forms';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker';
import { GlobalService } from '../../shared/services/global.service'; import { GlobalService } from '../../shared/services/global.service';
import { ApiService } from '../../shared/services/api.service'; import { ApiService } from '../../shared/services/api.service';
...@@ -16,24 +17,22 @@ export class RecoverComponent implements OnInit { ...@@ -16,24 +17,22 @@ 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.buildRecoverForm(); this.buildRecoverForm();
} }
public recoverWalletForm: FormGroup; public recoverWalletForm: FormGroup;
public creationDate: Date; public creationDate: Date;
private walletRecovery: WalletRecovery;
public isRecovering: boolean = false; public isRecovering: boolean = false;
public maxDate = new Date();
private responseMessage: string; private walletRecovery: WalletRecovery;
private errorMessage: string; private bsConfig: Partial<BsDatepickerConfig>;
ngOnInit() { ngOnInit() {
this.bsConfig = Object.assign({}, {showWeekNumbers: false, containerClass: 'theme-blue'});
console.log(new Date());
} }
private buildRecoverForm(): void { private buildRecoverForm(): void {
this.recoverWalletForm = this.fb.group({ this.recoverWalletForm = this.fb.group({
"walletMnemonic": ["", Validators.required],
"walletPassword": ["", Validators.required],
"walletName": ["", [ "walletName": ["", [
Validators.required, Validators.required,
Validators.minLength(1), Validators.minLength(1),
...@@ -41,6 +40,9 @@ export class RecoverComponent implements OnInit { ...@@ -41,6 +40,9 @@ export class RecoverComponent implements OnInit {
Validators.pattern(/^[a-zA-Z0-9]*$/) Validators.pattern(/^[a-zA-Z0-9]*$/)
] ]
], ],
"walletMnemonic": ["", Validators.required],
"walletDate": ["", Validators.required],
"walletPassword": ["", Validators.required],
"selectNetwork": ["test", Validators.required] "selectNetwork": ["test", Validators.required]
}); });
...@@ -66,24 +68,30 @@ export class RecoverComponent implements OnInit { ...@@ -66,24 +68,30 @@ export class RecoverComponent implements OnInit {
} }
formErrors = { formErrors = {
'walletName': '',
'walletMnemonic': '', 'walletMnemonic': '',
'walletDate': '',
'walletPassword': '', 'walletPassword': '',
'walletName': ''
}; };
validationMessages = { validationMessages = {
'walletMnemonic': {
'required': 'Please enter your 12 word phrase.'
},
'walletPassword': {
'required': 'A password is required.'
},
'walletName': { 'walletName': {
'required': 'A wallet name is required.', 'required': 'A wallet name is required.',
'minlength': 'A wallet name must be at least one character long.', 'minlength': 'A wallet name must be at least one character long.',
'maxlength': 'A wallet name cannot be more than 24 characters long.', 'maxlength': 'A wallet name cannot be more than 24 characters long.',
'pattern': 'Please enter a valid wallet name. [a-Z] and [0-9] are the only characters allowed.' 'pattern': 'Please enter a valid wallet name. [a-Z] and [0-9] are the only characters allowed.'
}, },
'walletMnemonic': {
'required': 'Please enter your 12 word phrase.'
},
'walletDate': {
'required': 'Please choose the date the wallet should sync from.'
},
'walletPassword': {
'required': 'A password is required.'
},
}; };
public onBackClicked() { public onBackClicked() {
...@@ -92,12 +100,16 @@ export class RecoverComponent implements OnInit { ...@@ -92,12 +100,16 @@ export class RecoverComponent implements OnInit {
public onRecoverClicked(){ public onRecoverClicked(){
this.isRecovering = true; this.isRecovering = true;
let recoveryDate = new Date(this.recoverWalletForm.get("walletDate").value);
recoveryDate.setDate(recoveryDate.getDate() - 1);
this.walletRecovery = new WalletRecovery( this.walletRecovery = new WalletRecovery(
this.recoverWalletForm.get("walletName").value, this.recoverWalletForm.get("walletName").value,
this.recoverWalletForm.get("walletMnemonic").value, this.recoverWalletForm.get("walletMnemonic").value,
this.recoverWalletForm.get("walletPassword").value, this.recoverWalletForm.get("walletPassword").value,
this.recoverWalletForm.get("selectNetwork").value, this.recoverWalletForm.get("selectNetwork").value,
this.creationDate recoveryDate
); );
this.recoverWallets(this.walletRecovery); this.recoverWallets(this.walletRecovery);
} }
...@@ -136,7 +148,6 @@ export class RecoverComponent implements OnInit { ...@@ -136,7 +148,6 @@ export class RecoverComponent implements OnInit {
.subscribe( .subscribe(
response => { response => {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
this.responseMessage = response;
alert("Your wallet has been recovered. \nYou will be redirected to the decryption page."); alert("Your wallet has been recovered. \nYou will be redirected to the decryption page.");
this.router.navigate(['']) this.router.navigate([''])
} }
......
...@@ -2,6 +2,7 @@ import { CommonModule } from '@angular/common'; ...@@ -2,6 +2,7 @@ import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core'; import { NgModule } from '@angular/core';
import { ReactiveFormsModule } from '@angular/forms'; import { ReactiveFormsModule } from '@angular/forms';
import { DatepickerModule } from 'angular2-material-datepicker' import { DatepickerModule } from 'angular2-material-datepicker'
import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
import { SetupComponent } from './setup.component'; import { SetupComponent } from './setup.component';
import { CreateComponent } from './create/create.component'; import { CreateComponent } from './create/create.component';
...@@ -13,6 +14,7 @@ import { RecoverComponent } from './recover/recover.component'; ...@@ -13,6 +14,7 @@ import { RecoverComponent } from './recover/recover.component';
@NgModule({ @NgModule({
imports: [ imports: [
BsDatepickerModule.forRoot(),
CommonModule, CommonModule,
DatepickerModule, DatepickerModule,
ReactiveFormsModule, ReactiveFormsModule,
......
...@@ -21,6 +21,7 @@ const isProd = (process.env.NODE_ENV === 'production'); ...@@ -21,6 +21,7 @@ const isProd = (process.env.NODE_ENV === 'production');
//add all external css to be added in our index.html--> like as if it's .angular-cli.json //add all external css to be added in our index.html--> like as if it's .angular-cli.json
const styles = [ const styles = [
"./node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
"./src/styles.css" "./src/styles.css"
]; ];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment